Model configuration

By default, Claude Code uses claude-3-7-sonnet-20250219. You can override this using the following environment variables:

# Anthropic API
ANTHROPIC_MODEL='claude-3-7-sonnet-20250219'
ANTHROPIC_SMALL_FAST_MODEL='claude-3-5-haiku-20241022'

# Amazon Bedrock
ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0'
ANTHROPIC_SMALL_FAST_MODEL='us.anthropic.claude-3-5-haiku-20241022-v1:0'

# Google Vertex AI
ANTHROPIC_MODEL='claude-3-7-sonnet@20250219'
ANTHROPIC_SMALL_FAST_MODEL='claude-3-5-haiku@20241022'

You can also set these variables using the global configuration:

# Configure for Anthropic API
claude config set --global env '{"ANTHROPIC_MODEL": "claude-3-7-sonnet-20250219"}'

# Configure for Bedrock
claude config set --global env '{"CLAUDE_CODE_USE_BEDROCK": "true", "ANTHROPIC_MODEL": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"}'

# Configure for Vertex AI
claude config set --global env '{"CLAUDE_CODE_USE_VERTEX": "true", "ANTHROPIC_MODEL": "claude-3-7-sonnet@20250219"}'

See our model names reference for all available models across different providers.

Use with third-party APIs

Claude Code requires access to both Claude 3.7 Sonnet and Claude 3.5 Haiku models, regardless of which API provider you use.

Connect to Amazon Bedrock

CLAUDE_CODE_USE_BEDROCK=1

If you’d like to access Claude Code via proxy, you can use the ANTHROPIC_BEDROCK_BASE_URL environment variable:

ANTHROPIC_BEDROCK_BASE_URL='https://your-proxy-url'

If you don’t have prompt caching enabled, also set:

DISABLE_PROMPT_CACHING=1

Requires standard AWS SDK credentials (e.g., ~/.aws/credentials or relevant environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY). To set up AWS credentials, run:

aws configure

Contact Amazon Bedrock for prompt caching for reduced costs and higher rate limits.

Users will need access to both Claude 3.7 Sonnet and Claude 3.5 Haiku models in their AWS account. If you have a model access role, you may need to request access to these models if they’re not already available. Access to Bedrock in each region is necessary because inference profiles require cross-region capability.

Connect to Google Vertex AI

CLAUDE_CODE_USE_VERTEX=1
CLOUD_ML_REGION=us-east5
ANTHROPIC_VERTEX_PROJECT_ID=your-project-id

If you’d like to access Claude Code via proxy, you can use the ANTHROPIC_VERTEX_BASE_URL environment variable:

ANTHROPIC_VERTEX_BASE_URL='https://your-proxy-url'

If you don’t have prompt caching enabled, also set:

DISABLE_PROMPT_CACHING=1

Claude Code on Vertex AI currently only supports the us-east5 region. Make sure your project has quota allocated in this specific region.

Users will need access to both Claude 3.7 Sonnet and Claude 3.5 Haiku models in their Vertex AI project.

Requires standard GCP credentials configured through google-auth-library. To set up GCP credentials, run:

gcloud auth application-default login

For the best experience, contact Google for heightened rate limits.

Connect though a proxy

When using Claude Code with an LLM proxy (like LiteLLM), you can control authentication behavior using the following environment variables and configs. Note that you can mix and match these with Bedrock and Vertex-specific settings.

Environment variables

  • ANTHROPIC_AUTH_TOKEN: Custom value for the Authorization and Proxy-Authorization headers (the value you set here will be prefixed with Bearer )
  • ANTHROPIC_CUSTOM_HEADERS: Custom headers you want to add to the request (in Name: Value format)
  • HTTP_PROXY: Set the HTTP proxy URL
  • HTTPS_PROXY: Set the HTTPS proxy URL

If you prefer to configure via a file instead of environment variables, you can add any of these variables to the env object in your global Claude config (in ~/.claude.json).

Global configuration options

  • apiKeyHelper: A custom shell script to get an API key (invoked once at startup, and cached for the duration of each session)

Was this page helpful?