OpenAI-compatible proxy for AtomCode CodingPlan. It supports local Python deployment and Cloudflare Workers deployment, with token refresh, quota status, plan claim helpers and upstream 429 retry.
This repository is a sanitized public template. Fill in your own access_token and refresh_token, or run atomcode login locally.
| Feature | Description |
|---|---|
| OpenAI-compatible API | /v1/models and /v1/chat/completions |
| Model aliases | Short names mapped to CodingPlan upstream model names |
| Token loading | Environment variables, ~/.atomcode/auth.toml, or ~/.codingplan/token.json |
| Token refresh | JSON refresh flow through AtomGit OAuth |
| Usage report | /usage and /status return plan/quota summary |
| Plan claim | /claim can call CodingPlan claim endpoint |
| Rate-limit handling | 429 retry with Retry-After support |
| Monitoring | monitor.py supports health/usage check and optional webhook |
| Alias | Upstream model | Recommended use |
|---|---|---|
deepseek-v4-flash |
deepseek-ai/DeepSeek-V4-Flash |
Default coding and general tasks |
deepseek-r1 |
deepseek-ai/DeepSeek-R1 |
Reasoning-heavy tasks |
qwen3-vl |
Qwen/Qwen3-VL-8B-Instruct |
Fast text and vision tasks |
glm-5 |
GLM-5.2 |
GLM compatibility and testing |
Use one of these methods.
atomcode loginThe proxy reads ~/.atomcode/auth.toml automatically.
export CODINGPLAN_TOKEN="<YOUR_ACCESS_TOKEN>"
export CODINGPLAN_REFRESH="<YOUR_REFRESH_TOKEN>"mkdir -p ~/.codingplan
cat > ~/.codingplan/token.json <<'EOF'
{
"access_token": "<YOUR_ACCESS_TOKEN>",
"refresh_token": "<YOUR_REFRESH_TOKEN>",
"expires_at": 0
}
EOF
chmod 600 ~/.codingplan/token.jsonexport CODINGPLAN_TOKEN="<YOUR_ACCESS_TOKEN>"
export CODINGPLAN_REFRESH="<YOUR_REFRESH_TOKEN>"
curl -fsSL https://raw.githubusercontent.com/yh594774855/codingplan-proxy/main/install.sh | bashManual run:
python3 proxy.py --host 127.0.0.1 --port 18999Expose to LAN:
PROXY_HOST=0.0.0.0 PROXY_PORT=18999 bash install.shCreate KV:
npx wrangler kv:namespace create CODINGPLAN_KVPut tokens into KV:
npx wrangler kv:key put --binding=CODINGPLAN_KV access_token "<YOUR_ACCESS_TOKEN>"
npx wrangler kv:key put --binding=CODINGPLAN_KV refresh_token "<YOUR_REFRESH_TOKEN>"
npx wrangler kv:key put --binding=CODINGPLAN_KV expires_at "0"Deploy:
npx wrangler deployWorker endpoints match the local proxy endpoints.
Health:
curl -s http://127.0.0.1:18999/healthUsage report:
curl -s http://127.0.0.1:18999/usage | python3 -m json.toolClaim Pro:
curl -s -X POST http://127.0.0.1:18999/claim \
-H "Content-Type: application/json" \
-d '{"plan_type":"Pro"}'Manual token refresh:
curl -s -X POST http://127.0.0.1:18999/refreshChat completion:
curl -s http://127.0.0.1:18999/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer any" \
-d '{"model":"deepseek-v4-flash","messages":[{"role":"user","content":"你好"}]}'Any OpenAI-compatible client can use:
| Field | Value |
|---|---|
| Base URL | http://127.0.0.1:18999/v1 |
| API Key | any |
| Model | deepseek-v4-flash, deepseek-r1, qwen3-vl, glm-5 |
opencode provider example:
{
"provider": {
"codingplan": {
"name": "codingplan",
"options": {
"baseURL": "http://127.0.0.1:18999/v1",
"apiKey": "any"
},
"models": {
"deepseek-v4-flash": { "name": "deepseek-v4-flash" },
"glm-5": { "name": "glm-5" },
"qwen3-vl": { "name": "qwen3-vl" }
}
}
}
}Run a one-shot check:
python3 monitor.py --base-url http://127.0.0.1:18999Send webhook when health fails, quota is exhausted, or usage exceeds 80%:
CODINGPLAN_WEBHOOK="https://example.com/webhook" python3 monitor.pyUse cron or your process manager to run monitor.py periodically.
auto_claim_pro.py starts at 09:59:59.800 Beijing time, sends one request every 200ms, and stops at 10:00:59.800.
python3 auto_claim_pro.pyEndpoint:
https://api.gitcode.com/api/v5/chat/completions
Required headers:
Authorization: Bearer <YOUR_ACCESS_TOKEN>
User-Agent: atomcode/4.25.7
Upstream model names:
| Alias | Upstream |
|---|---|
deepseek-v4-flash |
deepseek-ai/DeepSeek-V4-Flash |
deepseek-r1 |
deepseek-ai/DeepSeek-R1 |
qwen3-vl |
Qwen/Qwen3-VL-8B-Instruct |
glm-5 |
GLM-5.2 |
| Symptom | Check |
|---|---|
401 Bad credentials |
Token expired; run atomcode login or update token file |
Connection refused |
Proxy process is not running or port changed |
429 |
Quota/rate limit reached; proxy retries automatically |
| GLM first request is slow | Upstream cold start; subsequent requests are usually faster |
| Qwen stream fails | Use non-streaming requests for Qwen3-VL |
- Keep tokens in environment variables, KV, or local token files.
- Avoid committing token values to Git.
- Restrict public access if you expose the local proxy on
0.0.0.0. - Prefer Cloudflare Worker KV secrets for cross-device usage.