Command Code Provider API

Command Code provides API endpoints compatible with OpenAI and Anthropic formats. You can utilize your Command Code plan and credits for the available models using any client that supports those standards.


EndpointMethodFormat
https://api.commandcode.ai/provider/v1/chat/completionsPOSTOpenAI Chat Completions
https://api.commandcode.ai/provider/v1/messagesPOSTAnthropic Messages
https://api.commandcode.ai/provider/v1/modelsGETModels list

1

Get an API key

Create your API key from Studio.

Command Code API requires the Pro plan or higher. See Pricing & Limits for plan tiers.

2

Send a request

Once you have your API key, you can send a request to one of the following endpoints.

OpenAI Chat Completions /v1/chat/completions

curl https://api.commandcode.ai/provider/v1/chat/completions \ -H "Authorization: Bearer $CMD_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek/deepseek-v4-flash", "messages": [{"role": "user", "content": "Write a haiku about race conditions."}] }'

Anthropic Messages /v1/messages

curl https://api.commandcode.ai/provider/v1/messages \ -H "Authorization: Bearer $CMD_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Write a haiku about race conditions."}] }'

All Command Code models are available via the API, see Pricing & Limits for the full model list and per-model pricing. You can fetch the live models list at runtime from /provider/v1/models.

List models

curl https://api.commandcode.ai/provider/v1/models

Streaming is supported and can be received by setting stream: true.

Streaming

curl https://api.commandcode.ai/provider/v1/chat/completions \ -H "Authorization: Bearer $CMD_API_KEY" \ -H "Content-Type: application/json" \ --no-buffer \ -d '{ "model": "deepseek/deepseek-v4-flash", "messages": [{"role": "user", "content": "Count to 5."}], "stream": true, "stream_options": {"include_usage": true} }'

Both endpoints emit token usage at the end of every stream — OpenAI clients see a final usage chunk, Anthropic clients see usage in the message_delta event. No opt-in required.


OpenAI clients see the standard error envelope:

{ "error": { "message": "…", "type": "invalid_request_error" | "authentication_error" | "permission_error" | "rate_limit_error" | "server_error", "code": "…", "param": "…" } }

Anthropic clients see:

{ "type": "error", "error": { "type": "invalid_request_error" | "authentication_error" | "permission_error" | "rate_limit_error" | "api_error", "message": "…" } }

Here are the common error cases:

StatusCode / TypeWhen
400unsupported_modelModel isn't in the catalog (OpenAI shape only — code is on the OpenAI envelope; the Anthropic envelope has type: invalid_request_error instead).
400invalid_request_errorWrong endpoint for the model (Claude on /chat/completions or non-Anthropic on /messages), bad request body, or malformed JSON.
401authentication_errorMissing or invalid auth — pass Authorization: Bearer <token> (any route) or x-api-key: <token> (Anthropic SDK on /messages).
403upgrade_requiredUpgrade to Pro plan or higher.
429rate_limit_errorRate-limited by the upstream. Retry with backoff.
5xxserver_error / api_errorUpstream failure. The body carries the upstream provider's error message.

Which plans can use the Provider API?

Pro plan or higher. Accounts on the Go plan get a 403 upgrade_required on every /provider/v1/* request and need to upgrade before they can call the API.

Can I get multiple completions per request?

No. The endpoint returns one completion per request, n > 1 is rejected at the schema layer. Send parallel requests if you want multiple samples.

What content types are supported on user messages?

Text and image. Audio, file, and document parts are rejected by the schema. If the chosen model doesn't support vision the upstream provider returns its own error (we don't pre-gate per model).

Which models can I call?

Anthropic, OpenAI, and OSS models. See the Models section. Each endpoint accepts only its native wire shape: /chat/completions serves OpenAI and OSS models; /messages serves Anthropic models. Sending a Claude model to /chat/completions returns a 400 directing you to /messages, and vice versa.

Do I need a separate API key for this?

No. Use the same Command Code API key you generate for the CLI / Studio. Get one at CommandCode Studio under Settings → API Keys.