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.

1

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:

  1. Go to Virtual Keys in Portkey
  2. Add your provider (Anthropic, Bedrock, or Vertex AI) credentials
  3. Save and copy the virtual key ID

Save your virtual key ID - you’ll need it for Claude Code configuration.

2

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:

  1. Go to Configs in Portkey
  2. Create new config:
    {
        "virtual_key": "YOUR_VIRTUAL_KEY_ID",
        "override_params": {
            "model": "us.anthropic.claude-sonnet-4-20250514-v1:0"
        }
    }
    
  3. Save and note the Config ID

Configs are optional but recommended for production deployments with fallbacks and load balancing.

3

Get Your Portkey API Key

  1. Go to API Keys in Portkey
  2. Create or copy your existing API key
  3. 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):

{
  "env": {
    "ANTHROPIC_BEDROCK_BASE_URL": "https://api.portkey.ai/v1",
    "ANTHROPIC_CUSTOM_HEADERS": "x-portkey-api-key: YOUR_PORTKEY_API_KEY\nx-portkey-provider: bedrock\nx-portkey-virtual-key: YOUR_VIRTUAL_KEY",
    "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_VIRTUAL_KEY 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\nx-portkey-provider: bedrock\nx-portkey-virtual-key: YOUR_VIRTUAL_KEY",
    "ANTHROPIC_MODEL": "us.anthropic.claude-sonnet-4-20250514-v1:0",
    "CLAUDE_CODE_SKIP_BEDROCK_AUTH": 1,
    "CLAUDE_CODE_USE_BEDROCK": 1
  }
}

Adding Custom Metadata

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\nx-portkey-config: YOUR_CONFIG_ID\nx-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:

  1. Claude Code functioning normally in your terminal
  2. Requests appearing in your Portkey logs
  3. 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:

{
  "virtual_key": "YOUR_VIRTUAL_KEY",
  "cache": {
    "mode": "simple",
  }
}

Security & Compliance

References

Next Steps

For enterprise support and custom features, contact our enterprise team.