Create readme.md
Browse files
readme.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gemini ↔︎ OpenAI Proxy
|
| 2 |
+
|
| 3 |
+
Serve **Google Gemini 2.5 Pro** (or Flash) through an **OpenAI-compatible API**.
|
| 4 |
+
Plug-and-play with clients that already speak OpenAI—SillyTavern, llama.cpp, LangChain, the VS Code *Cline* extension, etc.
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## ✨ Features
|
| 9 |
+
|
| 10 |
+
| ✔ | Feature | Notes |
|
| 11 |
+
|---|---------|-------|
|
| 12 |
+
| `/v1/chat/completions` | Non-stream & stream (SSE) | Works with curl, ST, LangChain… |
|
| 13 |
+
| Vision support | `image_url` → Gemini `inlineData` | |
|
| 14 |
+
| Function / Tool calling | OpenAI “functions” → Gemini Tool Registry | |
|
| 15 |
+
| Reasoning / chain-of-thought | Sends `enable_thoughts:true`, streams `<think>` chunks | ST shows grey bubbles |
|
| 16 |
+
| 1 M-token context | Proxy auto-lifts Gemini CLI’s default 200 k cap | |
|
| 17 |
+
| CORS | Enabled (`*`) by default | Ready for browser apps |
|
| 18 |
+
| Zero external deps | Node 22 + TypeScript only | No Express |
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## 🚀 Quick start (local)
|
| 23 |
+
|
| 24 |
+
```bash
|
| 25 |
+
git clone https://huggingface.co/engineofperplexity/gemini-openai-proxy
|
| 26 |
+
cd gemini-openai-proxy
|
| 27 |
+
npm ci # install deps & ts-node
|
| 28 |
+
|
| 29 |
+
# launch on port 11434
|
| 30 |
+
npx ts-node src/server.ts
|
| 31 |
+
Optional env vars
|
| 32 |
+
PORT=3000 change listen port
|
| 33 |
+
GEMINI_API_KEY=<key> use your own key
|
| 34 |
+
|
| 35 |
+
Minimal curl test
|
| 36 |
+
bash
|
| 37 |
+
Copy
|
| 38 |
+
Edit
|
| 39 |
+
curl -X POST http://localhost:11434/v1/chat/completions \
|
| 40 |
+
-H "Content-Type: application/json" \
|
| 41 |
+
-d '{
|
| 42 |
+
"model": "gemini-2.5-pro-latest",
|
| 43 |
+
"messages":[{"role":"user","content":"Hello Gemini!"}]
|
| 44 |
+
}'
|
| 45 |
+
SillyTavern settings
|
| 46 |
+
Field Value
|
| 47 |
+
API Base URL http://127.0.0.1:11434/v1
|
| 48 |
+
Model gemini-2.5-pro-latest
|
| 49 |
+
Streaming On
|
| 50 |
+
Reasoning On → grey <think> lines appear
|
| 51 |
+
|
| 52 |
+
🐳 Docker
|
| 53 |
+
bash
|
| 54 |
+
Copy
|
| 55 |
+
Edit
|
| 56 |
+
# build once
|
| 57 |
+
docker build -t gemini-openai-proxy .
|
| 58 |
+
|
| 59 |
+
# run
|
| 60 |
+
docker run -p 11434:11434 \
|
| 61 |
+
-e GEMINI_API_KEY=$GEMINI_API_KEY \
|
| 62 |
+
gemini-openai-proxy
|
| 63 |
+
🗂 Project layout
|
| 64 |
+
pgsql
|
| 65 |
+
Copy
|
| 66 |
+
Edit
|
| 67 |
+
src/
|
| 68 |
+
server.ts – minimalist HTTP server
|
| 69 |
+
mapper.ts – OpenAI ⇄ Gemini transforms
|
| 70 |
+
chatwrapper.ts – thin wrapper around @google/genai
|
| 71 |
+
remoteimage.ts – fetch + base64 for vision
|
| 72 |
+
package.json – deps & scripts
|
| 73 |
+
Dockerfile
|
| 74 |
+
README.md
|
| 75 |
+
📜 License
|
| 76 |
+
MIT – free for personal & commercial use.
|