Claude Code

Route Claude Code through ToyGate by overriding the Anthropic base URL.

Integrations

Claude Code talks to the Anthropic Messages API by default. Override its base URL with the gateway's root and it will route through the gateway transparently — the gateway accepts Anthropic-format requests on /v1/messages for models whose provider_format is anthropic.

Config

bash
export ANTHROPIC_BASE_URL="https://api.toygate.store/anthropic"export ANTHROPIC_API_KEY="gw_..."

Note: no /v1 suffix here. Claude Code appends /v1/messages itself.

Verify

claude --model claude-opus-4-8 'Hello'

Expected: a normal Claude Code response. Streaming sessions stream; tool-call sessions make tool calls.

Model compatibility

Claude Code expects Anthropic-shaped responses (message_start, content_block_delta, message_stop). Use it only with model slugs whose provider_format is anthropic. The catalog page for each model shows its provider format; mismatches return upstream_invalid_response (502) — the gateway noticed the upstream sent the standard chat-completion shape when Claude Code expected Anthropic shape.

Troubleshooting

  • Tool calls don't work — verify that the model's capabilities.tools is true in the catalog. Some upstreams disable tool calls for specific model snapshots.
  • HTTP 401 with error.type: "authentication_error" — the key needs to be a gw_… key (not an Anthropic-issued key). The Anthropic-shaped response has no separate public code field; the corresponding OpenAI-compatible auth envelope uses code: null.
  • upstream_invalid_response — usually means you pointed Claude Code at a model whose provider_format is openai (not anthropic). Either switch models or use a Claude variant.

Gateway URL: https://api.toygate.store