Claude Code
Integrate Portkey with Claude Code for enterprise-grade AI coding assistance with observability and governance
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:
- 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.
For more details on Claude Code proxy configuration, see Anthropic’s documentation.
Edit your Claude Code settings file (~/.claude/settings.json
for global or .claude/settings.json
in your project):
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 keyYOUR_VIRTUAL_KEY
with the virtual key ID from Step 1- Update the model name if using a different Claude model
Edit your Claude Code settings file (~/.claude/settings.json
for global or .claude/settings.json
in your project):
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 keyYOUR_VIRTUAL_KEY
with the virtual key ID from Step 1- Update the model name if using a different Claude model
For Vertex AI integration:
Use ANTHROPIC_VERTEX_BASE_URL
specifically for Vertex AI, not the generic base URL.
For direct Anthropic API usage:
If you created a Portkey config for any provider:
When using a config, Portkey will use the provider settings defined in your config.
Complete Configuration Example
Here’s a full settings.json
example with permissions and Bedrock configuration:
Adding Custom Metadata
Track Claude Code usage by team, project, or user:
Verifying the Integration
After configuring, test Claude Code:
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:
Advanced Features
Caching for Faster Responses
Enable caching in your Portkey config to speed up repeated queries:
Security & Compliance
Access Controls
Set up fine-grained permissions and audit logging
Budget Management
Prevent overspending with hard budget limits
Audit Logs
Track all Claude Code usage for compliance
References
- Claude Code Proxy Documentation - Official Anthropic documentation for proxy configuration
- Portkey Virtual Keys - Secure credential management
- Portkey Configs - Advanced routing configuration
Next Steps
- Set up team workflows with role-based access
- Configure advanced routing for reliability
- Monitor usage patterns across your organization
For enterprise support and custom features, contact our enterprise team.