Claude Code CLI
Configure Anthropic's Claude Code CLI to route through LLMAI for unified billing and model access.
What This Does
Claude Code is Anthropic's official CLI for AI-assisted development. By configuring it to use LLMAI's endpoint, you can use any supported model — not just Claude — while consolidating all your AI spend under a single LLMAI account. Your token usage draws from your LLMAI balance automatically.
Setup
Step 1: Locate Your Settings File
Claude Code stores its configuration in a settings.json file. Find it based on your OS:
| OS | Path |
|---|---|
| macOS / Linux | ~/.claude/settings.json |
| Windows | %USERPROFILE%\.claude\settings.json |
If the file doesn't exist, create it.
Step 2: Configure Environment Variables
Open settings.json and add the following configuration:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.llmai.dev/",
"ANTHROPIC_AUTH_TOKEN": "YOUR_LLMAI_API_KEY",
"ANTHROPIC_MODEL": "gpt-5.4",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-5.3-codex",
"ANTHROPIC_SMALL_FAST_MODEL": "glm-5-turbo"
}
}Replace YOUR_LLMAI_API_KEY with your actual key from console.llmai.dev/keys.
Step 3: Alternative — Environment Variables in Shell
If you prefer not to modify the settings file, set environment variables in your shell:
export ANTHROPIC_BASE_URL="https://api.llmai.dev/"
export ANTHROPIC_AUTH_TOKEN="YOUR_LLMAI_API_KEY"Add these to your ~/.zshrc or ~/.bashrc to persist across sessions.
Step 4: Verify the Connection
Run Claude Code and start a conversation:
claudeTry a simple prompt to confirm the connection works.
Recommended Models for Claude Code
| Use Case | Model | Why |
|---|---|---|
| Complex reasoning & planning | gpt-5.4 | Highest capability |
| Code generation & refactoring | gpt-5.3-codex | Optimized for code |
| Large codebase analysis | gemini-3.1-pro | 1M+ token context |
| Quick operations | glm-5-turbo | Fast, low latency |
| Budget workloads | glm-5 | Cost-effective |
Troubleshooting
Connection refused or timeout
- Verify the base URL is exactly
https://api.llmai.dev/(with trailing slash for Claude Code) - Check that your API key is valid at console.llmai.dev/keys
Authentication errors
- Ensure
ANTHROPIC_AUTH_TOKENis set, notANTHROPIC_API_KEY— Claude Code expects the token variant - Remove any quotes around the key if you're setting it via shell export
Model not found errors
- Use model slugs exactly as shown in the Models reference
- Claude Code may require you to specify a model explicitly if the default isn't recognized
Notes
- Claude Code was designed for Claude models but works with any OpenAI-compatible endpoint
- The
ANTHROPIC_SMALL_FAST_MODELis used for background tasks — set it to a low-cost model - All token consumption appears in your LLMAI dashboard in real-time