CLI coding tools
NewUse Shannon as the model behind Claude Code, Codex CLI and other agent CLIs.
A coding tool needs three settings to work with Shannon: the base URL of the API, your API key, and a Shannon model id. This page gives the exact settings for Claude Code and Codex CLI, explains how the coding model shannon-coder-1 is counted, and lists the errors these tools meet.
Which endpoint each tool uses
| Tool | Endpoint | Base URL to set | Note |
|---|---|---|---|
| Claude Code | POST /v1/messagesPOST /v1/messages/count_tokens | https://api.shannon-ai.com | The tool adds /v1/messages to the base URL itself. |
| Codex CLI | POST /v1/responses | https://api.shannon-ai.com/v1 | The tool adds /responses to the base URL. |
| Other agent tools that speak the OpenAI chat format | POST /v1/chat/completions | https://api.shannon-ai.com/v1 | Set the base URL, the key and a Shannon model id in the tool's own settings. |
All three endpoints take the same API key, as Authorization: Bearer or as x-api-key. The headers anthropic-version, anthropic-beta and openai-beta that these tools send are accepted.
Select a Shannon model
Every request must name a model id that Shannon publishes. A coding tool sends the name of its own default model unless you tell it otherwise, and a name Shannon does not publish is answered with 400 and the message unknown model: <name>. No other name is mapped to a Shannon model, so set the model in the tool before the first request.
GET /v1/models lists every id with its context window. It needs no key. Models & pricing
| Model | Counted as | What it brings |
|---|---|---|
shannon-coder-1 | One call per request on /v1/messages and /v1/chat/completions. Tokens on /v1/responses. | The coding model. Text input, tool calls, 131,072-token context window. |
shannon-1.6-liteshannon-1.6-pro | Tokens from your balance. | General models with tool calls. shannon-1.6-lite suits the short background requests a tool makes. |
| Hosted open-weight models | Tokens from your balance, with cached input at 25% of the input price. | Tool calls, prompt caching for long sessions, and exact counts from /v1/messages/count_tokens. |
Coding tools steer the model with a long system prompt. The system prompt is applied by shannon-coder-1, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro and the hosted open-weight models, so select one of these for a coding tool.
Claude Code
Claude Code reads its connection from environment variables. Set them in the shell that starts it, or in the env block of ~/.claude/settings.json to keep them for every session.
# Install Claude Code
npm install -g @anthropic-ai/claude-code
# Where to send requests, and your Shannon API key
export ANTHROPIC_BASE_URL=https://api.shannon-ai.com
export ANTHROPIC_AUTH_TOKEN=YOUR_API_KEY
# Shannon model ids: the session model, and the model behind each built-in name
export ANTHROPIC_MODEL=shannon-coder-1
export ANTHROPIC_DEFAULT_OPUS_MODEL=shannon-coder-1
export ANTHROPIC_DEFAULT_SONNET_MODEL=shannon-coder-1
export ANTHROPIC_DEFAULT_HAIKU_MODEL=shannon-1.6-lite
# The context window of the session model
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=131072
claude {
"env": {
"ANTHROPIC_BASE_URL": "https://api.shannon-ai.com",
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
"ANTHROPIC_MODEL": "shannon-coder-1",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "shannon-coder-1",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "shannon-coder-1",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "shannon-1.6-lite",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "131072"
}
} | Variable | Description |
|---|---|
ANTHROPIC_BASE_URL | Where Claude Code sends its requests. Use the address without /v1. |
ANTHROPIC_AUTH_TOKEN | Your Shannon API key, sent as Authorization: Bearer. ANTHROPIC_API_KEY also works: it sends the key as x-api-key, and Claude Code asks once to approve it. |
ANTHROPIC_MODEL | The model of the session. claude --model <id> and /model <id> set the same thing. |
ANTHROPIC_DEFAULT_HAIKU_MODEL | The model for background requests such as session titles, and for anything that asks for haiku. |
ANTHROPIC_DEFAULT_SONNET_MODEL | The model used when a subagent or a command asks for sonnet. |
ANTHROPIC_DEFAULT_OPUS_MODEL | The model used when a subagent or a command asks for opus. |
CLAUDE_CODE_MAX_CONTEXT_TOKENS | The context window Claude Code assumes for the model. Use the context_window that GET /v1/models reports for the id you selected. |
- Set all three
ANTHROPIC_DEFAULT_…_MODELvariables. Subagents and some commands ask for a model by its built-in name, and each name must resolve to a Shannon id. - The sample points background requests at
shannon-1.6-lite, which is counted in tokens. Session titles and similar requests then do not use Coder calls. - Claude Code asks
POST /v1/messages/count_tokensfor the size of the context. The endpoint counts for the hosted open-weight models. With a Shannon id it answers400; Claude Code treats token counting as optional and estimates the size itself. Token counting
To check the address, the key and a model id before you start the tool, send one request by hand:
curl https://api.shannon-ai.com/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-1.6-lite",
"max_tokens": 16,
"messages": [{"role": "user", "content": "Say OK."}]
}' Codex CLI
Codex CLI talks to the Responses API. Describe Shannon as a model provider in ~/.codex/config.toml, select a Shannon model id there, and put your API key in the environment variable the provider names.
model = "shannon-coder-1"
model_provider = "shannon"
model_context_window = 131072
[model_providers.shannon]
name = "Shannon"
base_url = "https://api.shannon-ai.com/v1"
env_key = "SHANNON_API_KEY"
wire_api = "responses" # Install Codex CLI
npm install -g @openai/codex
# Your Shannon API key, under the name given as env_key
export SHANNON_API_KEY=YOUR_API_KEY
# Start it; --model selects another Shannon id for one run
codex
codex --model shannon-1.6-pro | Key | Description |
|---|---|
model | The Shannon model id. codex --model <id> sets it for one run. |
model_provider | The name of the provider block to use, here shannon. |
base_url | The API address with /v1. |
env_key | The name of the environment variable that holds your Shannon API key. |
wire_api | responses: Codex talks to POST /v1/responses. |
model_context_window | The context window of the model, so Codex compacts a long session in time. Use the context_window that GET /v1/models reports. |
/v1/responseskeeps no conversation on the server: each request carries the conversation ininput.previous_response_idis accepted for compatibility.- Function tools (
type: "function") are offered to the model on/v1/responses. - On
/v1/responses,shannon-coder-1is counted in tokens from your balance, not in Coder calls.
The same check for the Responses endpoint:
curl https://api.shannon-ai.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-1.6-lite",
"input": "Say OK."
}' The coding model and how it is counted
shannon-coder-1 is the Shannon model for coding agents. GET /v1/models reports it with a context window of 131,072 tokens, tool calls, reasoning and text input. It is counted in one of two ways, depending on the endpoint a tool uses.
| Endpoint | A request costs | Taken from |
|---|---|---|
/v1/messages | 1 call per request | The Coder call allowance of your plan. No tokens are taken from your balance. |
/v1/chat/completions | 1 call per request | The Coder call allowance of your plan. No tokens are taken from your balance. |
/v1/responses | Tokens, at $8.00 per 1M | Your balance, like any other model. The call allowance is not used. |
A call is one request, whatever its size. It is counted when the request is accepted, before the model answers. An agent session sends one request for every step it takes, so a long task uses many calls. The allowance depends on your plan and starts again every 4 hours, at 00:00, 04:00, 08:00, 12:00, 16:00 and 20:00 UTC.
| Plan | Calls per 4-hour window |
|---|---|
| Free | 3 |
| Plus | 20 |
| Standard | 40 |
| Pro | 60 |
The plan page shows the current numbers. Plans
When the calls of a window are used up, the request is answered with 429. On /v1/messages the same error comes in the Anthropic shape.
{
"error": {
"type": "rate_limit_error",
"message": "Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan"
}
} {
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan"
}
} Context overflow
When a conversation is larger than the context window of the model, /v1/chat/completions and /v1/messages answer with 400, the type invalid_request_error, the code context_length_exceeded and a message that starts with prompt is too long. Coding tools read this error to compact the session and send the request again. It is produced by shannon-coder-1, shannon-1.6-lite and shannon-1.6-pro.
{
"error": {
"type": "invalid_request_error",
"code": "context_length_exceeded",
"message": "prompt is too long: 140211 tokens > 131072 maximum",
"param": null
}
} {
"type": "error",
"error": {
"type": "invalid_request_error",
"code": "context_length_exceeded",
"message": "prompt is too long: 140211 tokens > 131072 maximum",
"param": null
}
} The message is prompt is too long: <sent> tokens > <limit> maximum. When the two numbers are not known it is prompt is too long. Please compact the conversation and try again.
On a stream the status is already 200, so the error arrives as an event and the stream then closes in the normal way:
data: {"error":{"message":"prompt is too long: 140211 tokens > 131072 maximum","type":"invalid_request_error","code":"context_length_exceeded","param":null}}
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","created":…,"model":"shannon-coder-1","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{…}}
data: [DONE] event: error
data: {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 140211 tokens > 131072 maximum"}}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{…}}
event: message_stop
data: {"type":"message_stop"} What an agent loop can rely on
| Topic | Behaviour |
|---|---|
| Tool schemas | Tool definitions are taken as the tool sends them. On shannon-coder-1 and shannon-1.6-*, JSON Schema keywords the model does not use, such as $schema, $ref, additionalProperties, default and title, are left out of what the model reads, and oneOf is read as anyOf. No request is refused for them. |
| Tool call arguments | In a stream, the arguments of a tool call arrive complete in one delta: tool_calls[].function.arguments, input_json_delta.partial_json or response.function_call_arguments.delta. |
| End of a tool turn | finish_reason: "tool_calls" on Chat Completions, stop_reason: "tool_use" on Messages. |
| Keep-alive | While the model works, /v1/messages sends event: ping and /v1/chat/completions sends a : ping comment line every 15 seconds. |
| Stopping a request | Closing the connection stops the stream. The turn itself runs to its end and is counted. |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
400 with unknown model: claude-… or unknown model: gpt-… | The tool sent its own default model name. Only published Shannon ids are served, and no other name is mapped to one. | Select a Shannon id: ANTHROPIC_MODEL and the three ANTHROPIC_DEFAULT_…_MODEL variables in Claude Code, model in the Codex config. |
400 with unknown model: and no name, from Codex CLI | The request named no model. /v1/responses needs one. | Set model in ~/.codex/config.toml or pass --model. |
401 with Missing authentication or Invalid API key | The key did not reach the API, or it is not a current key. A Shannon key starts with sk-. | Check that the variable is set in the shell that starts the tool. Copy the key again from Keys & usage. |
404 on every request | The base URL has one /v1 too many or too few for the tool. | Claude Code: the address without /v1. Codex CLI: the address with /v1. |
429 with Shannon Coder call quota reached | The Coder calls of the current 4-hour window are used up. | Wait for the next window, move to a plan with more calls, or select a model that is counted in tokens. |
429 with Quota exceeded | Your balance does not cover the request. | Add credit, or wait for the daily allowance of your plan at 00:00 UTC. |
400 with prompt is too long | The conversation is larger than the context window of the model. | Compact the session (/compact in both tools). Tell the tool the context window of the model so it compacts earlier. |
| Claude Code shows approximate context numbers | /v1/messages/count_tokens counts for the hosted open-weight models. With a Shannon id it answers 400, and Claude Code estimates the size itself. | Nothing to fix. Select a hosted open-weight model if you want exact counts. |
| A pasted screenshot is not taken into account | shannon-coder-1 takes text input. | Select a model that takes images for that session. |
Your key and your balance are on the Keys & usage page. Keys & usage