Skip to main content
Claude Code is Anthropic’s agentic coding tool that lives in your terminal. Add Portkey to get:
  • Multiple Claude Providers - Route through Anthropic, Bedrock, or Vertex AI
  • Observability - track costs, tokens, and latency for every request
  • Reliability - automatic fallbacks, retries, and caching
  • Governance - budget limits, usage tracking, and team access controls
This guide shows how to configure Claude Code with Portkey in under 5 minutes.
For enterprise deployments across teams, see Enterprise Governance.

1. Setup

1

Add Provider

Go to Model CatalogAdd Provider.Select Anthropic, Bedrock, or Vertex AI as your provider.
2

Configure Credentials

Enter your API key and create a slug like anthropic-prod.
3

Get Portkey API Key

Go to API Keys and generate your Portkey API key.

2. Configure Claude Code

Edit your Claude Code settings file (~/.claude/settings.json or .claude/settings.json in your project):
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.portkey.ai",
    "ANTHROPIC_AUTH_TOKEN": "dummy",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_PORTKEY_API_KEY\nx-portkey-provider: @anthropic-prod"
  }
}
This configuration works for Anthropic, Bedrock, and Vertex AI. See Anthropic’s documentation for more details.
Done! Monitor usage in the Portkey Dashboard.

Switch Providers

Change providers by updating the x-portkey-provider header:
@anthropic-prod
@bedrock-prod
@vertex-prod

Max Plan / Anthropic OAuth (Enterprise)

For Max plan or Anthropic OAuth users:
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.portkey.ai",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_PORTKEY_API_KEY"
  }
}
Want fallbacks, load balancing, or caching? Create a Portkey Config and add x-portkey-config: YOUR_CONFIG_ID to the headers. See Enterprise Governance for examples.

3. Enterprise Governance

For organizations deploying Claude Code across development teams, Portkey provides:
  • Cost Management: Budget limits and spend tracking per team
  • Access Control: Team-specific API keys with role-based permissions
  • Usage Analytics: Track patterns across teams and projects
  • Model Management: Control which models teams can access
Create team-specific providers with budget and rate limits:
  1. Go to Model CatalogAdd Provider
  2. Create providers for each team (e.g., anthropic-frontend, bedrock-backend)
  3. Set budget and rate limits per provider
Provision only the models each team needs:
Each team’s provider slug gives access only to their approved models.
Use Portkey Configs for fallbacks, load balancing, and caching.Example: Fallback from Anthropic to Bedrock
{
	"strategy": { "mode": "fallback" },
	"targets": [
		{ "provider": "@anthropic-prod" },
		{ "provider": "@bedrock-prod" }
	]
}
Create configs at Configs.
Generate API keys with metadata tracking:
from portkey_ai import Portkey

portkey = Portkey(api_key="YOUR_ADMIN_API_KEY")

api_key = portkey.api_keys.create(
    name="frontend-team",
    type="organisation",
    workspace_id="YOUR_WORKSPACE_ID",
    defaults={
        "metadata": {
            "environment": "production",
            "team": "frontend"
        }
    },
    scopes=["logs.view", "configs.read"]
)
See API Keys docs.
Track everything in the Portkey dashboard:
  • Cost by team
  • Model usage patterns
  • Request volumes and errors
  • Detailed logs for debugging

Portkey Features

Observability

Track 40+ metrics including cost, tokens, and latency across all providers. Filter by team or project using metadata.

Request Logs

Every request logged with complete details:
  • Full request/response payloads
  • Cost breakdown
  • Performance metrics

1600+ LLMs

Switch between any model through one interface:

Supported Providers

View all 1600+ supported models

Metadata Tracking

Track custom metrics:
  • Language and framework usage
  • Task types (generation vs. completion)
  • Project-specific patterns

Custom Metadata

Enterprise Access

Reliability

Security Guardrails

Protect your codebase:
  • Prevent API key exposure
  • Block malicious patterns
  • Enforce coding standards
  • PII detection and masking

Guardrails

Next Steps

Schedule a Demo

Schedule a 1:1 call with our team to see how Portkey can transform your development workflow with Claude Code
Join our Community
For enterprise support and custom features, contact our enterprise team.