A lightweight proxy for using the Cline API with 9router via a custom Anthropic-compatible or OpenAI-compatible provider.
- Cline's API defaults to streaming when
streamis not provided. - Some OpenAI-compatible clients expect a regular JSON response when
streamis absent. - 9router works better with Anthropic-compatible providers when using multiple API keys on a single custom provider.
- Some upstream SSE events can be empty or carry no
choices, which can trigger errors likeProvider returned no completion choices for this model.
POST /v1/chat/completionsPOST /v1/messagesGET /v1/modelsGET /health
npm startDefault local URL:
http://localhost:8787/v1
Recommended: use a custom Anthropic-compatible provider in 9router.
Anthropic-compatible:
- Base URL:
http://HOST:8787/v1 - API key: your Cline API key
- Model: the Cline model ID, e.g.
xiaomi/mimo-v2.5ordeepseek/deepseek-v4-flash - Messages endpoint: 9router will automatically append
/messages
OpenAI-compatible is also available:
- Base URL:
http://HOST:8787/v1 - API key: your Cline API key
- Model: the model ID
- Chat completions endpoint:
/chat/completions
The proxy forwards the API key and model field from 9router to Cline. For OpenAI-compatible, it reads Authorization: Bearer .... For Anthropic-compatible, it reads x-api-key or Authorization: Bearer ....
If 9router runs in a separate container, do not use
localhostunless the proxy is in the same container. Use the host IP, Docker service name, or the proxy's public domain.
All variables are optional. Defaults are sufficient for most deployments.
PORT=8787
CLINE_BASE_URL=https://api.cline.bot/api/v1
REQUEST_TIMEOUT_MS=120000
Non-streaming:
curl -s http://localhost:8787/v1/chat/completions \
-H 'authorization: Bearer YOUR_CLINE_API_KEY' \
-H 'content-type: application/json' \
-d '{
"model": "MODEL_ID",
"messages": [{"role":"user","content":"Hello"}]
}'Streaming:
curl -N http://localhost:8787/v1/chat/completions \
-H 'authorization: Bearer YOUR_CLINE_API_KEY' \
-H 'content-type: application/json' \
-d '{
"model": "MODEL_ID",
"stream": true,
"messages": [{"role":"user","content":"Hello"}]
}'Anthropic-compatible non-streaming:
curl -s http://localhost:8787/v1/messages \
-H 'x-api-key: YOUR_CLINE_API_KEY' \
-H 'anthropic-version: 2023-06-01' \
-H 'content-type: application/json' \
-d '{
"model": "MODEL_ID",
"max_tokens": 128,
"messages": [{"role":"user","content":"Hello"}]
}'docker build -t cline-proxy .
docker run --rm -p 8787:8787 cline-proxyClone the repo:
git clone https://github.com/defyma/cline-proxy.git
cd cline-proxyCopy and edit the env file:
cp .env.example .env
# edit .env as neededStart:
docker compose pull
docker compose up -dCompose uses image:
ghcr.io/defyma/cline-proxy:latest
This repository uses GitHub Actions to build and push the Docker image to the GitHub Container Registry (GHCR).
The pipeline produces the following tags:
ghcr.io/defyma/cline-proxy:latest— on push tomainghcr.io/defyma/cline-proxy:main— branch tagghcr.io/defyma/cline-proxy:v1.0.0— on git tagghcr.io/defyma/cline-proxy:sha-<short>— per commit
To pull the image manually:
docker pull ghcr.io/defyma/cline-proxy:latest