Claude Code Integration
Claude Code is Anthropic's official command-line tool for agentic AI coding. It lets developers delegate complex coding tasks to Claude directly from the terminal, including reading and writing files, executing commands, searching codebases, and working through multi-step programming workflows.
Claude Code supports custom API endpoints through environment variables, allowing you to route requests through LLM API to access multiple models via a single integration.
Prerequisites
- An LLM API account with an API key
- Claude Code installed or accessible
Setup
Get Your LLM API Key
- Log in to your LLM API dashboard
- Click Create Key to Start
- Copy your new API key immediately — it will only be shown once
- Store the key securely (e.g., in a password manager or
.env file)
INFO
LLM API is an OpenAI-compatible gateway that gives you access to dozens of AI models through a
single API key and endpoint.
Point Claude Code at LLM API
Set the LLM API base URL before launching Claude Code:
export ANTHROPIC_BASE_URL="https://api.llmapi.ai"
Authenticate
Authenticate with one of the following environment variables. ANTHROPIC_AUTH_TOKEN is preferred — it skips the in-app confirmation prompt that ANTHROPIC_API_KEY triggers.
# Preferred
export ANTHROPIC_AUTH_TOKEN="your-llm-api-key-here"
# Or
export ANTHROPIC_API_KEY="your-llm-api-key-here"
WARN
If you are already logged into Claude Code with an Anthropic account, log out first so the
environment variable is used:
/logout
Choose Default Models (optional)
Override the default Claude models Claude Code uses for each tier. Any model from the LLM API models page is supported.
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-7"
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-6"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
To route a tier through a specific provider, prefix the model with the provider name. For example, to serve Sonnet via AWS Bedrock:
export ANTHROPIC_DEFAULT_SONNET_MODEL="aws-bedrock/claude-sonnet-4-6"
Persist the Configuration (optional)
To avoid re-exporting every session, add the variables to your shell profile (~/.bashrc, ~/.zshrc) or a project .env file:
ANTHROPIC_BASE_URL=https://api.llmapi.ai
ANTHROPIC_AUTH_TOKEN=your-llm-api-key-here
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-7
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6
ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
Launch Claude Code
claude
If you authenticated with ANTHROPIC_API_KEY, Claude Code will prompt you on startup:
Detected a custom API key in your environment
ANTHROPIC_API_KEY: sk-ant-...c7e934b29bd14f27b14e
Do you want to use this API key?
1. Yes
Select Yes to route requests through LLM API. This prompt does not appear when using ANTHROPIC_AUTH_TOKEN.
Test the Integration
Send a test request from within Claude Code to confirm requests reach LLM API. You can verify activity in your LLM API dashboard.
INFO
Setting ANTHROPIC_BASE_URL overrides the default Anthropic endpoint. Claude Code will send all
requests to LLM API instead, giving you access to every model in the catalog.
Benefits of Using LLM API with Claude Code
- Multi-Provider Access: Use models from OpenAI, Anthropic, Google, and more through a single API
- Cost Control: Track and limit your AI spending with detailed usage analytics
- Unified Billing: One account for all providers instead of managing multiple API keys
- Caching: Reduce costs with response caching for repeated requests
INFO
View all available models on the models page.