Claude Code · Facts verified 2026-10-13

How do I use Portkey with Claude Code?

Put ANTHROPIC_BASE_URL=https://api.portkey.ai in ~/.claude/settings.json, add your Portkey key and a provider header such as @anthropic-prod in ANTHROPIC_CUSTOM_HEADERS, and set the model names explicitly. Tokens bill to the provider behind that integration.

settings.jsonapi.portkey.ai
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.portkey.ai",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_PORTKEY_API_KEY",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_PORTKEY_API_KEY\nx-portkey-provider: @anthropic-prod",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-20250514",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-20250514",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-20250514"
  },
  "model": "claude-sonnet-4-20250514"
}

Portkey's examples still name Claude 4 models; replace them with current IDs from your Model Catalog. ~/.claude/settings.json keeps the values for every session. Run /status in Claude Code to check the base URL.

Setup in four steps

  1. In Portkey's Model Catalog, add a provider integration with your Anthropic, Bedrock or Vertex credentials. Its slug, such as @anthropic-prod, is what Claude Code will name.
  2. Create a Portkey API key.
  3. Paste one of the blocks above into ~/.claude/settings.json, with no /v1 on the base URL.
  4. Start Claude Code and send a prompt; the request should appear in Portkey's logs. A lightning symbol there marks a passthrough request.

Gotchas in Portkey's own docs

IssueWhat happensWhat to do
/v1 in the base URL"API Error: 500 fetch failed"Use https://api.portkey.ai exactly
No model namesRequests failSet ANTHROPIC_DEFAULT_SONNET_MODEL, _OPUS_ and _HAIKU_ to IDs your provider serves
Old example IDsThe docs' examples name Claude 4 models from May 2025Replace them with current IDs from your Model Catalog
Beta featuresAnthropic beta headers are dropped unless forwardedAdd forward_headers: ["anthropic-beta"] to your Portkey config
Other modelsSwap the provider slug, for example @openai-prod, and set ANTHROPIC_MODELTest tool use on a real task; some models handle it worse than Claude
Claude Max sign-inDocumented under Enterprise; costs show as $0 in PortkeyUse it for logs and limits, not billing

From Portkey's Claude Code docs, October 13, 2026. Portkey also recommends running the latest Claude Code release.

Every way to run other models in Claude Code

What it costs

Portkey bills logs, not tokens: free for 10,000 logged requests a month, then $49 on Production. The tokens go to your Anthropic, Bedrock or other provider account at its own price, which for a typical coding-agent day is $3.53 on Claude Sonnet 5.5 and $7.06 on Opus 5.5 at list price, measured in our Agent Burn Index. Portkey can cap a key's spend on Enterprise and for select Pro customers; it does not pick a cheaper model for routine steps.

Portkey pricing in full

The catch

Portkey's setup has four moving parts: a provider integration, a key, a custom header and three model variables. Each is a place where a typo turns into a 500, so change one at a time and watch the logs.

Where Standard Compute fits

Standard Compute needs two of those values, the base URL and a key, and keeps Claude Code's own model names. It sits in front of Claude Code like Portkey does, and also works on the bill: routine steps go to efficient models, inside a plan from $19 that stops at its budget. If your company already governs every LLM call through Portkey, stay there.

FAQ

What is the Portkey base URL for Claude Code?

https://api.portkey.ai, with no /v1, because Claude Code adds /v1/messages itself. Portkey's troubleshooting table lists the /v1 suffix as the cause of "500 fetch failed".

Can Claude Code use GPT or other models through Portkey?

Yes. Portkey documents swapping the provider slug in ANTHROPIC_CUSTOM_HEADERS, for example to @openai-prod, and setting ANTHROPIC_MODEL; Portkey translates the request. How well a model handles Claude Code's tools varies.

Does Portkey work with Claude Code on Bedrock or Vertex?

Yes. Point the provider header at a Bedrock or Vertex integration (Portkey's examples use @bedrock-prod and @vertex-prod) and use that platform's model IDs.

Does Portkey work with Codex CLI?

Yes. Portkey documents a model provider with base_url https://api.portkey.ai/v1 and env_key PORTKEY_API_KEY, with wire_api set to chat by default or responses, and models named @provider-slug/model.

Related guides