Claude Code is Anthropic’s agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster through natural language commands.
With Portkey integration, you can enhance Claude Code with enterprise features:
Unified AI Gateway - Route Claude Code through multiple providers (Anthropic, Bedrock, Vertex AI)
Centralized Logs - Track all Claude Code interactions
Security & Governance - Set rate limits, implement access controls, and audit all AI usage
This integration uses Portkey’s Gateway Passthrough feature. Advanced Portkey capabilities - such as cost calculation, reliability features, and more are not supported yet.
1. Setting up Portkey
Before integrating with Claude Code, you’ll need to set up the core Portkey components.
Create Virtual Key
Virtual Keys securely manage your LLM provider API keys with built-in controls:
Budget limits and rate limiting
Secure credential storage
Provider switching without code changes
To create a virtual key:
Go to Virtual Keys in Portkey
Add your provider (Anthropic, Bedrock, or Vertex AI) credentials
Save and copy the virtual key ID
Save your virtual key ID - you’ll need it for Claude Code configuration.
Create Config (Optional)
Configs enable advanced routing features. You can either use a virtual key directly or create a config for more control.
To create a config:
Go to Configs in Portkey
Create new config:
{
"provider" : "@YOUR_PROVIDER_ID" ,
"override_params" : {
"model" : "us.anthropic.claude-sonnet-4-20250514-v1:0"
}
}
Save and note the Config ID
Configs are optional but recommended for production deployments with fallbacks and load balancing.
Get Your Portkey API Key
Go to API Keys in Portkey
Create or copy your existing API key
Keep it ready for the next steps
2. Integrate Portkey with Claude Code
Claude Code uses a settings.json
file for configuration. You’ll need to modify the environment variables to route requests through Portkey.
Amazon Bedrock Google Vertex AI Anthropic API Using Config Edit your Claude Code settings file (~/.claude/settings.json
for global or .claude/settings.json
in your project):
{
"env" : {
"ANTHROPIC_BEDROCK_BASE_URL" : "https://api.portkey.ai/v1" ,
"ANTHROPIC_CUSTOM_HEADERS" : "x-portkey-api-key: YOUR_PORTKEY_API_KEY \n x-portkey-provider: @your-bedrock-ai-provider-slug" ,
"ANTHROPIC_MODEL" : "us.anthropic.claude-sonnet-4-20250514-v1:0" ,
"CLAUDE_CODE_SKIP_BEDROCK_AUTH" : 1 ,
"CLAUDE_CODE_USE_BEDROCK" : 1
}
}
The CLAUDE_CODE_SKIP_BEDROCK_AUTH
and CLAUDE_CODE_USE_BEDROCK
must be set as numbers (not strings).
Replace:
YOUR_PORTKEY_API_KEY
with your Portkey API key
YOUR_PROVIDER
with the virtual key ID from Step 1
Update the model name if using a different Claude model
Complete Configuration Example
Here’s a full settings.json
example with permissions and Bedrock configuration:
{
"permissions" : {
"allow" : [
"Bash(npm run lint)" ,
"Bash(npm run test:*)" ,
"Read(~/.zshrc)"
],
"deny" : [
"Bash(curl:*)"
]
},
"env" : {
"ANTHROPIC_BEDROCK_BASE_URL" : "https://api.portkey.ai/v1" ,
"ANTHROPIC_CUSTOM_HEADERS" : "x-portkey-api-key: YOUR_PORTKEY_API_KEY \n x-portkey-provider: @your-bedrock-ai-provider-slug" ,
"ANTHROPIC_MODEL" : "us.anthropic.claude-sonnet-4-20250514-v1:0" ,
"CLAUDE_CODE_SKIP_BEDROCK_AUTH" : 1 ,
"CLAUDE_CODE_USE_BEDROCK" : 1
}
}
Track Claude Code usage by team, project, or user:
{
"env" : {
"ANTHROPIC_BEDROCK_BASE_URL" : "https://api.portkey.ai/v1" ,
"ANTHROPIC_CUSTOM_HEADERS" : "x-portkey-api-key: YOUR_PORTKEY_API_KEY \n x-portkey-config: YOUR_CONFIG_ID \n x-portkey-metadata: { \" _user \" : \" john.doe \" , \" team \" : \" engineering \" , \" project \" : \" backend-api \" }" ,
"CLAUDE_CODE_SKIP_BEDROCK_AUTH" : 1 ,
"CLAUDE_CODE_USE_BEDROCK" : 1
}
}
Verifying the Integration
After configuring, test Claude Code:
# Start Claude Code
claude
# Ask it to perform a task
> explain the authentication flow in this codebase
You should see:
Claude Code functioning normally in your terminal
Requests appearing in your Portkey logs
Metrics updating in your Portkey dashboard
3. Set Up Enterprise Governance for Claude Code
When deploying Claude Code across your organization, implement these governance controls:
Team-Based Access Control
Create separate providers for each team with specific limits:
Engineering Team
Budget: $500/month
Models: Claude Sonnet only
Rate limit: 100 requests/minute
Data Science Team
Budget: $1000/month
Models: All Claude models
Rate limit: 200 requests/minute
Deploy team-specific settings.json
through your configuration management:
{
"env" : {
"ANTHROPIC_BEDROCK_BASE_URL" : "https://api.portkey.ai/v1" ,
"ANTHROPIC_CUSTOM_HEADERS" : "x-portkey-api-key: TEAM_PORTKEY_API_KEY \n x-portkey-provider: @your-bedrock-team-ai-provider-slug" ,
"ANTHROPIC_MODEL" : "us.anthropic.claude-sonnet-4-20250514-v1:0" ,
"CLAUDE_CODE_SKIP_BEDROCK_AUTH" : 1 ,
"CLAUDE_CODE_USE_BEDROCK" : 1
}
}
Centralized Policy Management
For enterprise deployments, use policy files to enforce settings:
macOS : /Library/Application Support/ClaudeCode/policies.json
Linux/WSL : /etc/claude-code/policies.json
Example policy file:
{
"env" : {
"ANTHROPIC_BEDROCK_BASE_URL" : "https://api.portkey.ai/v1" ,
"ANTHROPIC_CUSTOM_HEADERS" : "x-portkey-api-key: ENTERPRISE_API_KEY \n x-portkey-config: ENTERPRISE_CONFIG_ID" ,
"CLAUDE_CODE_SKIP_BEDROCK_AUTH" : 1 ,
"CLAUDE_CODE_USE_BEDROCK" : 1
},
"permissions" : {
"deny" : [
"Bash(rm -rf*)" ,
"Edit(/etc/*)"
]
}
}
Usage Monitoring & Alerts
Set up monitoring in Portkey:
Create Alerts
Budget threshold warnings at 80%
Unusual usage patterns
Failed request spikes
Regular Reviews
Weekly cost reports by team
Model usage distribution
Performance metrics
Compliance Tracking
Export logs for audit trails
Monitor for sensitive data in prompts
Track user activity patterns
Advanced Features
Caching for Faster Responses
Enable caching in your Portkey config to speed up repeated queries:
{
"provider" : "@YOUR_PROVIDER" ,
"cache" : {
"mode" : "simple" ,
}
}
Security & Compliance
References
Next Steps