Claude Code
CLI dev agent from Anthropic. Connects over the native /v1/messages endpoint — your own key and catalog models.
Claude Code speaks the native Anthropic protocol: POST /v1/messages, and the gateway accepts the key both via the Authorization: Bearer header and via x-api-key. The ApiMira gateway answers this endpoint directly — set it up with five environment variables or a single settings file.
How to connect
- 1Set ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN (the key is created in the dashboard and shown once), ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL and ANTHROPIC_SMALL_FAST_MODEL — in your terminal or in the Claude Code settings file.
- 2So you do not have to set the variables again in every new terminal window, move them into the env block of the settings file ~/.claude/settings.json (on Windows that is C:\Users\Your name\.claude\settings.json) — the ready-made file is in the snippet below. The Claude Code extension for VS Code reads the same file: it launches the same CLI and never sees variables from a neighbouring terminal, so restart the editor after editing it. Settings for a single project go into .claude/settings.local.json in its root — that file stays out of git, so the key never reaches the repository.
- 3Set ANTHROPIC_BASE_URL to the gateway address without /v1 — Claude Code appends /v1/messages itself, and a stray /v1 turns into a 404.
- 4Set ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL and ANTHROPIC_SMALL_FAST_MODEL to our own Model IDs from the catalog. All three are required: the gateway does not recognize Anthropic's own model names and returns 404 on background tasks, even though the main conversation keeps working. ANTHROPIC_DEFAULT_HAIKU_MODEL is the current name for the background-model variable in Claude Code, ANTHROPIC_SMALL_FAST_MODEL is the old one (it usually still works); both are set so this does not depend on your Claude Code version.
- 5Run claude — agentic mode works, including reading and editing files: the gateway supports tool calls. Streaming responses work too.
export ANTHROPIC_BASE_URL=https://apimira.com
export ANTHROPIC_AUTH_TOKEN=am-YOUR_KEY
export ANTHROPIC_MODEL=google/gemini-3.7-flash
export ANTHROPIC_DEFAULT_HAIKU_MODEL=google/gemini-3.7-flash
export ANTHROPIC_SMALL_FAST_MODEL=google/gemini-3.7-flash
claudecount_tokens returns an estimate, not an exact figure — use it as a guide rather than cutting your budget close to it; images are included in that estimate. Image input works: an image block with a base64 source (PNG, JPEG or WebP, up to 5 MB each, up to 50 per request) reaches the model, including an image returned by a tool — Claude Code reads an image file, and it arrives as a separate user turn. A URL instead of base64 (a source of type url) is not fetched, and a model without the "Sees images" mark answers with unsupported_capability. The endpoint rejects document blocks and the top_k parameter with a clear error, so attached files will not work in Claude Code. The thinking field and thinking blocks, on the contrary, are accepted and never passed on: there will be no extended thinking in the answer, but no error either — the MAX_THINKING_TOKENS variable is not needed. The whole prompt is capped at 400,000 characters (roughly 100k tokens), and some models add a context ceiling on top: crossing either limit returns an explicit error, not a silent cut; image bytes do not count towards the character cap. There is no cap of our own on max_tokens — Claude Code sets 32,000, and exactly that much is held on your balance for the answer, so keep a reserve. The cache_control field is accepted but ignored: manual cache markup is not supported. Caching still works automatically for models that list a cached-input rate on the Models page: when a prompt starts the same way as the previous one, those tokens are billed at the discounted rate, and their count arrives in usage.cache_read_input_tokens. This page's general rule that a parameter is never dropped silently is about the OpenAI-compatible /v1/chat/completions; here the request body is built from a whitelist of Anthropic fields, and anything outside it is exactly what gets dropped silently — cache_control above, for instance. Only unknown fields go quietly: document blocks and the top_k parameter come back as an error with code unsupported_parameter instead of disappearing from the request.
Function calling is supported, so agentic modes work. Strict JSON mode (response_format) and the retired functions format are rejected with an unsupported_parameter error — the parameter is never silently dropped. Image input is accepted by models marked "Sees images" on the Models page: a content part of type image_url with a data:image/png;base64,… URL (PNG, JPEG or WebP, up to 5 MB each, up to 50 per request). Remote URLs are not fetched, and a model without that mark answers with unsupported_capability — both errors name the reason outright.