commandcode-api-proxy 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,12 @@
1
+ <a href="#"><img src="./.github/assets/banner.webp" alt="Banner"></a>
2
+
1
3
  # Command Code API Proxy
2
4
 
3
- **OpenAI-compatible API proxy for [Command Code](https://commandcode.ai).**
4
- Use your Command Code subscription from **any** OpenAI-compatible client — OpenCode, Continue, the OpenAI SDK, or plain `curl`.
5
+ [![npm version](https://img.shields.io/npm/v/commandcode-api-proxy)](https://www.npmjs.com/package/commandcode-api-proxy)
6
+ [![downloads/month](https://img.shields.io/npm/dm/commandcode-api-proxy)](https://www.npmjs.com/package/commandcode-api-proxy)
5
7
 
6
- ```
7
- npx commandcode-api-proxy
8
- ```
8
+ **OpenAI-compatible API proxy for [Command Code](https://commandcode.ai).**
9
+ Use your Command Code subscription from **any** OpenAI-compatible client — OpenCode, Claude Code, or plain `curl`.
9
10
 
10
11
  ## Why?
11
12
 
@@ -18,10 +19,16 @@ Command Code exposes two API surfaces:
18
19
 
19
20
  This proxy talks `/alpha/generate` upstream and standard OpenAI downstream — so your existing plan works from any tool.
20
21
 
21
- ## Quick start
22
+ ## Run the proxy
22
23
 
23
24
  ```bash
24
- # Run directly (no install)
25
+ # Clone & run from source
26
+ git clone https://github.com/thaolaptrinh/commandcode-api-proxy.git
27
+ cd commandcode-api-proxy
28
+ npm install
29
+ npm run build && npm start
30
+
31
+ # Or run directly (no install)
25
32
  npx commandcode-api-proxy
26
33
 
27
34
  # Or install globally
@@ -29,17 +36,19 @@ npm install -g commandcode-api-proxy
29
36
  commandcode-api-proxy
30
37
  ```
31
38
 
32
- ### Authentication
39
+ On first run, the proxy prompts for your Command Code API key (get it from
40
+ https://commandcode.ai/settings). Other ways to provide it are in
41
+ [Authentication](#authentication).
33
42
 
34
- The proxy loads your API key from (in order of priority):
43
+ ## Authentication
35
44
 
36
- 1. `--api-key` CLI flag: `npx commandcode-api-proxy --api-key user_xxx`
37
- 2. `CC_API_KEY` environment variable
38
- 3. `~/.config/commandcode-api-proxy/auth.json` (saved via `auth login`)
45
+ Provide your API key via `--api-key`, the `CC_API_KEY` env var, or save it
46
+ with `auth login` (stored at `~/.config/commandcode-api-proxy/auth.json`).
39
47
 
40
- On first run without a key, the proxy prompts you to enter one and persists it.
48
+ ### CLI auth commands
41
49
 
42
- #### CLI auth commands
50
+ > From source, replace `commandcode-api-proxy` with `npm run auth --`
51
+ > (e.g. `npm run auth -- login`).
43
52
 
44
53
  ```bash
45
54
  # Save a new API key
@@ -52,9 +61,7 @@ commandcode-api-proxy auth login --force
52
61
  commandcode-api-proxy auth logout
53
62
  ```
54
63
 
55
- Get your API key from https://commandcode.ai/settings.
56
-
57
- ### CLI options
64
+ ## CLI options
58
65
 
59
66
  | Option | Description | Default |
60
67
  | --------------------- | --------------------------------- | ----------- |
@@ -64,97 +71,44 @@ Get your API key from https://commandcode.ai/settings.
64
71
  | `--setup-opencode` | Generate OpenCode provider config | — |
65
72
  | `--setup-claude-code` | Generate Claude Code model config | — |
66
73
 
67
- ## Endpoints
68
-
69
- ### `POST /v1/chat/completions` (OpenAI)
70
-
71
- ```bash
72
- curl http://127.0.0.1:8787/v1/chat/completions \
73
- -H "Authorization: Bearer proxy-managed" \
74
- -H "Content-Type: application/json" \
75
- -d '{
76
- "model": "deepseek/deepseek-v4-pro",
77
- "messages": [{"role": "user", "content": "Hello!"}],
78
- "stream": true
79
- }'
80
- ```
81
-
82
- ### `POST /v1/messages` (Anthropic)
83
-
84
- ```bash
85
- curl http://127.0.0.1:8787/v1/messages \
86
- -H "x-api-key: proxy-managed" \
87
- -H "Content-Type: application/json" \
88
- -d '{
89
- "model": "claude-sonnet-4-5-20250929",
90
- "max_tokens": 4096,
91
- "messages": [{"role": "user", "content": "Hello!"}],
92
- "stream": true
93
- }'
94
- ```
95
-
96
- ### `POST /v1/messages/count_tokens` (Anthropic)
97
-
98
- ```bash
99
- curl http://127.0.0.1:8787/v1/messages/count_tokens \
100
- -H "x-api-key: proxy-managed" \
101
- -H "Content-Type: application/json" \
102
- -d '{
103
- "messages": [{"role": "user", "content": "Hello!"}]
104
- }'
105
- ```
106
-
107
- ### Anthropic model mapping
108
-
109
- Anthropic clients send Claude model IDs (e.g., `claude-sonnet-4-5-20250929`).
110
- The proxy maps them to CC models via a config file with glob wildcards:
111
-
112
- ```bash
113
- npx commandcode-api-proxy --setup-claude-code
114
- ```
115
-
116
- This writes `~/.config/commandcode-api-proxy/anthropic-models.json`:
117
-
118
- ```json
119
- {
120
- "default": "deepseek/deepseek-v4-pro",
121
- "mappings": {
122
- "claude-sonnet-*": "deepseek/deepseek-v4-pro",
123
- "claude-opus-*": "deepseek/deepseek-v4-pro",
124
- "claude-haiku-*": "deepseek/deepseek-v4-flash"
125
- }
126
- }
127
- ```
128
-
129
- **Glob matching:** `*` matches any characters. First matching pattern wins —
130
- put specific patterns before general ones (e.g. `claude-sonnet-*` before
131
- `claude-*`). Edit the file to customize mappings, then restart the proxy.
74
+ Equivalent env vars (lower priority than CLI flags):
132
75
 
133
- Non-Claude model IDs pass through unchanged.
76
+ | Env var | Description |
77
+ | ---------------- | -------------------------------------------- |
78
+ | `HOST` | Bind address |
79
+ | `PORT` | Port |
80
+ | `CC_API_KEY` | Command Code API key |
81
+ | `CC_API_BASE` | Upstream API base URL |
82
+ | `CC_CLI_VERSION` | CLI version sent upstream |
83
+ | `LOG_LEVEL` | Log level (`info`, `debug`, etc.) |
134
84
 
135
- **Optional override:** Set `ANTHROPIC_DEFAULT_MODEL` env var to override the
136
- config file's `default` field without editing the file.
85
+ ## Endpoints
137
86
 
138
- ### Anthropic limitations
87
+ | Endpoint | Protocol |
88
+ | -------------------------------- | --------- |
89
+ | `GET /health` | — |
90
+ | `GET /v1/models` | OpenAI |
91
+ | `POST /v1/chat/completions` | OpenAI |
92
+ | `POST /v1/messages` | Anthropic |
93
+ | `POST /v1/messages/count_tokens` | Anthropic |
139
94
 
140
- - **Thinking signatures**: placeholder only (not cryptographically signed).
141
- - **Cache control**: stripped (no CC analogue).
142
- - **Count tokens**: heuristic estimate, not exact.
143
- - **Built-in/server tools** (`computer_`, `bash_`, `web_search_`, etc.):
144
- rejected with `invalid_request_error`. Only custom tools supported.
145
- - **`metadata`, `top_k`, `top_p`, `service_tier`**: accepted but dropped.
95
+ All endpoints accept any auth token (use `proxy-managed`) — the proxy injects
96
+ your real Command Code key upstream.
146
97
 
147
98
  ## Client configuration
148
99
 
149
100
  ### OpenCode
150
101
 
151
- Run setup (writes to `~/.config/opencode/opencode.json`):
102
+ Run setup to auto-generate the provider config at `~/.config/opencode/opencode.json`:
152
103
 
153
104
  ```bash
154
105
  npx commandcode-api-proxy --setup-opencode
155
106
  ```
156
107
 
157
- Or add manually:
108
+ All CC models are listed directly — pick the one you want from the model selector.
109
+
110
+ Or add a `commandcode` provider manually — point `baseURL` at the proxy and
111
+ use any model ID from the [Model aliases](#model-aliases) table:
158
112
 
159
113
  ```json
160
114
  {
@@ -168,90 +122,33 @@ Or add manually:
168
122
  "apiKey": "proxy-managed"
169
123
  },
170
124
  "models": {
171
- "deepseek-v4-pro": {
172
- "name": "DeepSeek V4 Pro",
173
- "limit": { "context": 1048576, "output": 393216 }
174
- },
175
- "deepseek-v4-flash": {
176
- "name": "DeepSeek V4 Flash",
177
- "limit": { "context": 1048576, "output": 393216 }
178
- },
179
- "MiniMax-M2.7": { "name": "MiniMax M2.7", "limit": { "context": 204800, "output": 32768 } },
180
- "MiniMax-M2.5": { "name": "MiniMax M2.5", "limit": { "context": 204800, "output": 32768 } },
181
- "GLM-5.1": { "name": "GLM-5.1", "limit": { "context": 200000, "output": 131072 } },
182
- "GLM-5": { "name": "GLM-5", "limit": { "context": 200000, "output": 131072 } },
183
- "Kimi-K2.6": { "name": "Kimi K2.6", "limit": { "context": 262144, "output": 98304 } },
184
- "Kimi-K2.5": { "name": "Kimi K2.5", "limit": { "context": 262144, "output": 98304 } },
185
- "Qwen3.6-Max-Preview": {
186
- "name": "Qwen 3.6 Max Preview",
187
- "limit": { "context": 262144, "output": 65536 }
188
- },
189
- "Qwen3.6-Plus": {
190
- "name": "Qwen 3.6 Plus",
191
- "limit": { "context": 1048576, "output": 65536 }
192
- },
193
- "Qwen3.7-Max": { "name": "Qwen 3.7 Max", "limit": { "context": 1048576, "output": 65536 } },
194
- "Qwen3.7-Plus": {
195
- "name": "Qwen 3.7 Plus",
196
- "limit": { "context": 1048576, "output": 65536 }
197
- },
198
- "Step-3.5-Flash": {
199
- "name": "Step 3.5 Flash",
200
- "limit": { "context": 262144, "output": 65536 }
201
- },
202
- "mimo-v2.5": { "name": "MiMo V2.5", "limit": { "context": 1048576, "output": 131072 } }
125
+ "deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
203
126
  }
204
127
  }
205
128
  }
206
129
  }
207
130
  ```
208
131
 
209
- ### OpenAI Python SDK
210
-
211
- ```python
212
- from openai import OpenAI
213
-
214
- client = OpenAI(
215
- base_url="http://127.0.0.1:8787/v1",
216
- api_key="proxy-managed",
217
- )
218
-
219
- response = client.chat.completions.create(
220
- model="deepseek/deepseek-v4-pro",
221
- messages=[{"role": "user", "content": "Hello!"}],
222
- )
223
- ```
224
-
225
- ### Continue
226
-
227
- ```json
228
- {
229
- "models": [
230
- {
231
- "title": "Command Code",
232
- "provider": "openai",
233
- "model": "deepseek/deepseek-v4-pro",
234
- "apiKey": "proxy-managed",
235
- "apiBase": "http://127.0.0.1:8787/v1"
236
- }
237
- ]
238
- }
239
- ```
240
-
241
132
  ### Claude Code
242
133
 
243
- Run the proxy's setup to generate model config and Claude Code settings:
134
+ Claude Code only offers three tiers `sonnet`, `opus`, `haiku`. The setup
135
+ maps each tier to a Command Code model via env vars in `claude-settings.json`:
244
136
 
245
137
  ```bash
246
138
  npx commandcode-api-proxy --setup-claude-code
247
139
  ```
248
140
 
249
- This creates:
141
+ If a settings file already exists, re-run with `--force` to overwrite it.
250
142
 
251
- 1. Model mapping config at `~/.config/commandcode-api-proxy/anthropic-models.json`
252
- 2. Claude Code settings at `~/.config/commandcode-api-proxy/claude-settings.json`
143
+ | Claude Code tier | Env var | Maps to |
144
+ | ---------------- | -------------------------------- | --------------------------- |
145
+ | `sonnet` | `ANTHROPIC_DEFAULT_SONNET_MODEL` | `deepseek/deepseek-v4-pro` |
146
+ | `opus` | `ANTHROPIC_DEFAULT_OPUS_MODEL` | `deepseek/deepseek-v4-pro` |
147
+ | `haiku` | `ANTHROPIC_DEFAULT_HAIKU_MODEL` | `deepseek/deepseek-v4-flash`|
253
148
 
254
- Then run:
149
+ Edit those env vars in the settings file to point at other CC models. To force
150
+ every `claude-*` request to a single model regardless of tier, set
151
+ `ANTHROPIC_DEFAULT_MODEL`. Then run:
255
152
 
256
153
  ```bash
257
154
  claude --settings ~/.config/commandcode-api-proxy/claude-settings.json
@@ -264,37 +161,26 @@ alias claude-proxy="claude --settings ~/.config/commandcode-api-proxy/claude-set
264
161
  claude-proxy
265
162
  ```
266
163
 
267
- ### Anthropic SDK (Python)
268
-
269
- ```python
270
- from anthropic import Anthropic
271
-
272
- client = Anthropic(
273
- base_url="http://127.0.0.1:8787/v1",
274
- api_key="proxy-managed",
275
- )
276
-
277
- message = client.messages.create(
278
- model="claude-sonnet-4-5-20250929",
279
- max_tokens=4096,
280
- messages=[{"role": "user", "content": "Hello!"}],
281
- )
282
- ```
283
-
284
164
  ## Model aliases
285
165
 
286
166
  Short names work in addition to full model IDs:
287
167
 
288
- | Alias | Maps to |
289
- | ------------------------------------- | ---------------------------- |
290
- | `deepseek-v4-pro`, `deepseek-v4` | `deepseek/deepseek-v4-pro` |
291
- | `deepseek-v4-flash`, `deepseek-flash` | `deepseek/deepseek-v4-flash` |
292
- | `minimax-m2.7`, `minimax-m2.5` | `MiniMaxAI/MiniMax-*` |
293
- | `glm-5.1`, `glm-5` | `zai-org/GLM-*` |
294
- | `kimi-k2.6`, `kimi-k2.5` | `moonshotai/Kimi-*` |
295
- | `qwen3.6-max`, `qwen3.6-plus` | `Qwen/Qwen3.6-*` |
296
- | `step3.5` | `stepfun/Step-3.5-Flash` |
297
- | `mimo-v2.5` | `xiaomi/mimo-v2.5` |
168
+ | Alias | Maps to |
169
+ | -------------------------------------------------- | ------------------------------ |
170
+ | `deepseek-v4-pro`, `deepseek-v4`, `deepseek-pro` | `deepseek/deepseek-v4-pro` |
171
+ | `deepseek-v4-flash`, `deepseek-flash` | `deepseek/deepseek-v4-flash` |
172
+ | `kimi-k2.6`, `kimi2.6` | `moonshotai/Kimi-K2.6` |
173
+ | `kimi-k2.5`, `kimi2.5` | `moonshotai/Kimi-K2.5` |
174
+ | `glm-5.1` | `zai-org/GLM-5.1` |
175
+ | `glm-5` | `zai-org/GLM-5` |
176
+ | `minimax-m2.7`, `minimax2.7` | `MiniMaxAI/MiniMax-M2.7` |
177
+ | `minimax-m2.5`, `minimax2.5` | `MiniMaxAI/MiniMax-M2.5` |
178
+ | `qwen3.6-max`, `qwen-3.6-max` | `Qwen/Qwen3.6-Max-Preview` |
179
+ | `qwen3.6-plus`, `qwen-3.6-plus` | `Qwen/Qwen3.6-Plus` |
180
+ | `qwen3.7-max`, `qwen-3.7-max` | `Qwen/Qwen3.7-Max` |
181
+ | `qwen3.7-plus`, `qwen-3.7-plus` | `Qwen/Qwen3.7-Plus` |
182
+ | `step3.5`, `step-3.5-flash` | `stepfun/Step-3.5-Flash` |
183
+ | `mimo-v2.5`, `mimo2.5` | `xiaomi/mimo-v2.5` |
298
184
 
299
185
  Any model ID is passed through as-is — the proxy does not validate against a fixed list.
300
186
 
package/dist/models.json CHANGED
@@ -36,7 +36,13 @@
36
36
  "qwen-3.6-plus": "Qwen/Qwen3.6-Plus",
37
37
  "qwen3.6-plus": "Qwen/Qwen3.6-Plus",
38
38
  "step-3.5-flash": "stepfun/Step-3.5-Flash",
39
- "step3.5": "stepfun/Step-3.5-Flash"
39
+ "step3.5": "stepfun/Step-3.5-Flash",
40
+ "mimo-v2.5": "xiaomi/mimo-v2.5",
41
+ "mimo2.5": "xiaomi/mimo-v2.5",
42
+ "qwen3.7-max": "Qwen/Qwen3.7-Max",
43
+ "qwen-3.7-max": "Qwen/Qwen3.7-Max",
44
+ "qwen3.7-plus": "Qwen/Qwen3.7-Plus",
45
+ "qwen-3.7-plus": "Qwen/Qwen3.7-Plus"
40
46
  },
41
47
  "contextWindows": {
42
48
  "deepseek/deepseek-v4-pro": 1048576,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commandcode-api-proxy",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "OpenAI-compatible API proxy for Command Code. Use your Command Code subscription from any OpenAI client.",
5
5
  "keywords": [
6
6
  "ai-proxy",