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 virtual keys with budget limits and rate controls. 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 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, giving you:
Claude Code → Portkey Gateway → Anthropic / Bedrock / Vertex AI

Quick Start (All Providers)

The configuration pattern is the same for all providers — only the provider name and model names change:
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.portkey.ai/v1",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_PORTKEY_API_KEY\nx-portkey-provider: anthropic\nx-portkey-virtual-key: YOUR_VIRTUAL_KEY",
    "ANTHROPIC_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": [
    { "virtual_key": "anthropic-virtual-key" },
    { "virtual_key": "bedrock-virtual-key" },
    { "virtual_key": "vertex-virtual-key" }
  ]
}

Budget Controls for Agentic Coding

Claude Code can run expensive agentic loops. Set hard limits on your virtual keys:
  • Cost limits: Maximum spend per day/week/month
  • 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
  • Metadata for grouping related requests

Caching

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

Common Configuration

Adding Metadata

Track Claude Code usage by team, project, or user:
{
  "env": {
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_KEY\nx-portkey-provider: anthropic\nx-portkey-virtual-key: YOUR_VIRTUAL_KEY\nx-portkey-metadata: {\"_user\": \"john.doe\", \"team\": \"engineering\"}"
  }
}

Troubleshooting

SymptomCauseFix
Requests not appearingOld Claude Code versionRun claude update
Authentication errorsWrong virtual keyVerify virtual key ID in Portkey dashboard
Model not foundWrong model name for providerCheck provider-specific model IDs
See provider-specific pages for detailed troubleshooting.

Next Steps

Last modified on February 2, 2026