Model Mapping
Model mapping is how Claude Code knows which model name to send in API requests when you’re using a non-Anthropic provider. Claude Code internally uses roles like “Sonnet”, “Opus”, and “Haiku” to pick models for different tasks. Provider templates remap these roles to the actual model names offered by the provider.
The environment variables
Provider templates set these variables in the wrapper script:
ANTHROPIC_MODEL: the default model for general useANTHROPIC_SMALL_FAST_MODEL: the model used for quick, cheap tasks (maps to Haiku)ANTHROPIC_DEFAULT_SONNET_MODEL: the model used for standard coding tasksANTHROPIC_DEFAULT_OPUS_MODEL: the model used for complex reasoningANTHROPIC_DEFAULT_HAIKU_MODEL: the model used for fast responses
Example mappings
GLM template:
- Default:
glm-5.1 - Fast:
glm-5-turbo - Sonnet/Opus/Haiku: all mapped to
glm-5-turboorglm-5.1
MiniMax template:
- All roles map to
MiniMax-M3
OpenRouter template:
- You pick the model during setup, and all roles map to it
Why it matters
Claude Code picks models based on task complexity. A quick autocomplete uses the “Haiku” role. A complex refactor uses the “Opus” role. If these aren’t mapped correctly, Claude Code sends the wrong model name to the provider and the request fails.
Customizing
You can change model mappings by editing the wrapper script. For example, if a provider releases a new model, you can update ANTHROPIC_DEFAULT_SONNET_MODEL without waiting for a claude-multi template update.
Related terms
- Provider Template
A pre-configured set of environment variables, base URLs, and model mappings that tells Claude Code how to reach a specific LLM provider.
- Base URL
The API endpoint URL that Claude Code sends requests to. Each provider template sets a different base URL to route traffic to the right service.
- Context Window
The maximum number of tokens a model can process in a single conversation, including both input and output.
- Auto-Compaction
A mechanism that summarizes earlier conversation history when the context window fills up, keeping the session running without losing too much information.