Claude Code
Point Claude Code at AdaptiqAI with two environment variables. Your context is read from Native Context Memory for free on every request, and Claude Code's own status line shows it as cache reads.
adaptiq-claude command that starts Claude Code on AdaptiqAI without touching your own Claude Code setup. This page is the same thing written out.1. Environment
Set these in the terminal you start Claude Code from. The two that do the work are the base URL and the token; the rest keep Claude Code from asking for a model, a context window or a server-side review the endpoint does not have.
# Where requests go. No /v1 on the base URL: Claude Code adds it.
export ANTHROPIC_BASE_URL=https://api.adaptiqai.com
# One key only. A key of your own for Anthropic would go along too,
# and the gateway refuses a request that carries two keys.
unset ANTHROPIC_API_KEY
export ANTHROPIC_AUTH_TOKEN=ak-...
# Every model alias points at the same model, so no part of Claude Code
# (background tasks, sub-agents) asks for a model the endpoint does not run.
export ANTHROPIC_MODEL=adaptiq-deepseek-v4.1-flash
export ANTHROPIC_DEFAULT_FABLE_MODEL=adaptiq-deepseek-v4.1-flash
export ANTHROPIC_DEFAULT_OPUS_MODEL=adaptiq-deepseek-v4.1-flash
export ANTHROPIC_DEFAULT_SONNET_MODEL=adaptiq-deepseek-v4.1-flash
export ANTHROPIC_DEFAULT_HAIKU_MODEL=adaptiq-deepseek-v4.1-flash
export CLAUDE_CODE_SUBAGENT_MODEL=adaptiq-deepseek-v4.1-flash
# The context window Claude Code may assume. For a model id it does not
# know it assumes 200K and compacts there; this says otherwise.
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000
# No attribution line at the top of the system prompt: it carries a
# fingerprint that changes per request, so a prompt cache never matches.
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
# Since 2.1.251 an agent's own model beats the subagent alias; and behind
# a gateway, auto mode asks the server, which cannot, to review actions.
export CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1
export CLAUDE_CODE_AUTO_MODE_SERVER=0
claudeenv block of ~/.claude/settings.json wins over these exports, so take any other gateway's out of it. If you prefer the settings file, put the same values there:{
"env": {
"ANTHROPIC_BASE_URL": "https://api.adaptiqai.com",
"ANTHROPIC_AUTH_TOKEN": "ak-...",
"ANTHROPIC_MODEL": "adaptiq-deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "adaptiq-deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "adaptiq-deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "adaptiq-deepseek-v4.1-flash",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "adaptiq-deepseek-v4.1-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "adaptiq-deepseek-v4.1-flash",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000",
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
"CLAUDE_CODE_SUBAGENT_MODEL_FORCE": "1",
"CLAUDE_CODE_AUTO_MODE_SERVER": "0"
}
}2. The context window: [1m] or CLAUDE_CODE_MAX_CONTEXT_TOKENS
Claude Code assumes a 200K window for a model id it does not recognise and compacts the conversation there. Two ways to tell it otherwise: append [1m] to the model id in every alias above (adaptiq-deepseek-v4.1-flash[1m]), which Claude Code reads as a 1M-context model and strips before sending; or set CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000 as the Console does. One million is the most Claude Code can be told; a larger window on our side cannot be declared to the client.
3. Turn auto-compact off
Native Context Memory keeps the whole history outside the prompt. Claude Code's auto-compact summarises the conversation and rewrites that history, so turn it off: in Claude Code, /config › Auto-compact › off. Set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 as well, so a compaction is never triggered by the assumed window before the setting takes effect (the variable's range is 100,000 to 1,000,000; the exact setting name may change between releases).
4. What the usage fields mean
Every response carries the Anthropic usage object. The names are Anthropic's; the four numbers are the four classes on the price card, and the bill is their sum times the prices:
"usage": {
"input_tokens": 1500,
"cache_creation_input_tokens": 1500,
"cache_read_input_tokens": 310500,
"output_tokens": 1840
}| Field | Price card class | What it counts |
|---|---|---|
input_tokens | input_tokens | New tokens this request: your text, tool results, images. Charged. |
cache_creation_input_tokens | memory_write_tokens | Tokens written to Native Context Memory. Charged once. |
cache_read_input_tokens | memory_read_tokens | Context served from memory: the conversation so far, attached knowledge, a parent's memory. Free. |
output_tokens | output_tokens | What the model produced, reasoning included. Charged. |
Streaming: message_start.usage carries the input and cache fields, message_delta.usage the final output_tokens. cache_control on blocks is accepted and ignored: memory is always on. POST /v1/messages/count_tokens returns the live input_tokens the request would prefill plus cache_read_input_tokens for the session's memory. The price card has the prices; the three shapes show the same request as Chat Completions and Responses.