Skip to main content
Claude Code is one of the most popular AI coding tools for boosting developer productivity. Platform teams use Portkey to roll out Claude Code across their organization—without handing out raw API keys or losing visibility into usage.

Why Platform Teams Use Portkey

Governance & Access Control

No raw API keys. Create a single config, add team members to workspaces, and enable Claude Code instantly. Track who’s using what.

Cost Visibility

Claude Code can run up bills fast with agentic loops. See exactly what each team, project, or developer is spending—and set hard budget limits.

Workspace Separation

Isolate teams with separate workspaces. Each gets its own budget, rate limits, and access controls. Perfect for enterprise multi-team setups.

Provider Agnostic

Route through Anthropic, Bedrock, or Vertex AI. Switch providers with a single config change—no developer workflow changes needed.
For developers: Setup takes 2 minutes. Copy a config, paste it, start coding.
Important: Always use the latest version of Claude Code. Older versions may not work with Portkey’s gateway.
claude update

Choose Your Provider

How It Works

Portkey acts as an LLM gateway between Claude Code and your chosen provider. All requests route through Portkey’s unified endpoint, giving you:
Claude Code → Portkey Gateway → Anthropic / Bedrock / Vertex AI
Key difference from native Claude Code setup: Portkey uses a single ANTHROPIC_BASE_URL endpoint for all providers. You don’t need provider-specific URLs like ANTHROPIC_BEDROCK_BASE_URL or ANTHROPIC_VERTEX_BASE_URL.

Quick Start (All Providers)

The configuration pattern is the same for all providers — only the provider slug and model names change:
{
  "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"
}
Model names are required. Each provider uses different model IDs. Without the correct model settings, requests will fail.

Why Use Portkey with Claude Code?

Cross-Provider Fallbacks

Never lose a coding session due to provider outages. Configure automatic failover:
{
  "strategy": { "mode": "fallback" },
  "targets": [
    { "provider": "@anthropic-prod" },
    { "provider": "@bedrock-prod" },
    { "provider": "@vertex-prod" }
  ]
}

Budget Controls for Agentic Coding

Claude Code can run expensive agentic loops. Set hard limits:
  • Cost limits: Maximum spend per day/week/month
  • Token limits: Maximum tokens consumed
  • Rate limits: Requests per minute/hour

Full Session Observability

Track every request in your coding session:
  • Request/response logs with full context
  • Token usage and cost breakdowns
  • Latency metrics
  • Trace IDs for grouping related requests

Caching

Reduce costs and latency for repeated queries (common in iterative coding):
{
  "cache": { "mode": "simple" }
}

Common Configuration

Forward Headers (Required)

Some Claude Code features need the anthropic-beta header forwarded. Add this to your Portkey Config:
{
  "provider": "@your-provider-slug",
  "forward_headers": ["anthropic-beta"]
}

Trace IDs

Group requests by session or project:
{
  "env": {
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_KEY\nx-portkey-provider: @anthropic-prod\nx-portkey-trace-id: my-project-session"
  }
}

Troubleshooting

SymptomCauseFix
API Error: 500 fetch failedWrong base URLUse https://api.portkey.ai (no /v1)
Lightning symbol (⚡) in logsPassthrough requestCheck provider slug and API key
Requests not appearingOld Claude Code versionRun claude update
See provider-specific pages for detailed troubleshooting.

Next Steps