How Claude Code connects
Claude Code reaches Portkey in the Anthropic Messages format, throughANTHROPIC_BASE_URL, whichever provider sits behind it. Don’t set CLAUDE_CODE_USE_BEDROCK or CLAUDE_CODE_USE_VERTEX.
Because Claude Code thinks it is talking to the Claude API, it sends the full set of Anthropic features even when Portkey routes to Bedrock or Vertex AI. Portkey bridges the difference: it strips beta flags the provider doesn’t support, rewrites the ones the provider renamed, and drops body fields the provider rejects.
What Portkey handles
Versions are the enterprise gateway release that added each behavior. Self-hosted gateways need at least that version.
On gateways older than v2.22.0, add
"forward_headers": ["anthropic-beta"] to the config, or features like extended context stay off with no error.
Claude Code settings
Show gateway models in /model
- Keep
ANTHROPIC_AUTH_TOKENset. Claude Code skips discovery when the credential is only inANTHROPIC_CUSTOM_HEADERS. - With
x-portkey-providerset, the picker lists that provider’s models. Without a provider, the gateway returns models across the workspace. - Claude Code keeps only IDs that contain
claudeoranthropic. Bedrock IDs likeus.anthropic.claude-sonnet-4-5-20250929-v1:0pass; non-Claude models from the universal provider don’t appear.
Bedrock and Vertex AI upstreams
If a request fails with400 and Extra inputs are not permitted, a pre-release Anthropic feature reached a provider that doesn’t accept it. Turn pre-release features off in Claude Code:
strict, defer_loading), structured output format and MCP tool search. Effort, extended context and interleaved thinking stay on.
Gateway caching
Portkey’s simple cache caches complete responses and requires the entire request body to match; a stable system prefix alone does not produce hits whenmessages changes between turns. Anthropic prompt caching is separate: it can reuse an unchanged prefix across turns and reports cache-read token counts. Claude Code v2.1.181 and later keep the system prompt prefix stable within a conversation; on older versions, set CLAUDE_CODE_ATTRIBUTION_HEADER=0 to help preserve that provider-side prefix cache.
Guardrails
Claude Code expects thesystem, tools and messages content of earlier turns to reach the provider unchanged. Guardrails that rewrite the request, such as PII redaction, can cause:
- Cache misses on every turn
400errors saying a thinking block isbound to a different conversation. Claude Code recovers by dropping earlier thinking blocks.
strip_scaffolding to avoid false positives from Claude Code’s system reminders.
Requests that skip the gateway
Two checks callapi.anthropic.com directly and never appear in Portkey logs:
- The fast mode availability check
- The WebFetch domain safety check
api.anthropic.com, fast mode can report a connectivity error while requests through Portkey keep working. See fast mode behind gateways.
Troubleshooting
Portkey is now PRISMA AIRS AI Gateway. See it in action.
Contact Us

