Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AtomCode CodingPlan Proxy

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.

Features

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

Models

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

Token Setup

Use one of these methods.

Method 1: atomcode login

atomcode login

The proxy reads ~/.atomcode/auth.toml automatically.

Method 2: environment variables

export CODINGPLAN_TOKEN="<YOUR_ACCESS_TOKEN>"
export CODINGPLAN_REFRESH="<YOUR_REFRESH_TOKEN>"

Method 3: token file

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.json

Local Deployment

export CODINGPLAN_TOKEN="<YOUR_ACCESS_TOKEN>"
export CODINGPLAN_REFRESH="<YOUR_REFRESH_TOKEN>"
curl -fsSL https://raw.githubusercontent.com/yh594774855/codingplan-proxy/main/install.sh | bash

Manual run:

python3 proxy.py --host 127.0.0.1 --port 18999

Expose to LAN:

PROXY_HOST=0.0.0.0 PROXY_PORT=18999 bash install.sh

Cloudflare Worker Deployment

Create KV:

npx wrangler kv:namespace create CODINGPLAN_KV

Put 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 deploy

Worker endpoints match the local proxy endpoints.

API Usage

Health:

curl -s http://127.0.0.1:18999/health

Usage report:

curl -s http://127.0.0.1:18999/usage | python3 -m json.tool

Claim 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/refresh

Chat 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":"你好"}]}'

Tool Configuration

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" }
      }
    }
  }
}

Monitoring And Notification

Run a one-shot check:

python3 monitor.py --base-url http://127.0.0.1:18999

Send webhook when health fails, quota is exhausted, or usage exceeds 80%:

CODINGPLAN_WEBHOOK="https://example.com/webhook" python3 monitor.py

Use cron or your process manager to run monitor.py periodically.

Daily Claim Helper

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.py

Direct Upstream API

Endpoint:

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

Troubleshooting

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

Security Notes

  • 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.

About

AtomCode CodingPlan 免费 LLM API 本地代理部署包(脱敏分享)— 支持 DeepSeek V4 Flash / DeepSeek R1 / Qwen3-VL / GLM-5,一键部署 Python 本地代理或 Cloudflare Worker,标准 OpenAI 兼容接口

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages