Making Claude Code Ask for the Right Backend: Mapping Its Hardcoded Model Names to Aggregator Aliases
Claude Code sends requests using Claude-specific model identifiers. Learn how these hardcoded names are mapped to aggregator aliases, and how to intercept or remap them so your requests can be routed to GPT, DeepSeek, Qwen, or other models available on the aggregator.
Why Claude Code's model names need translating
Claude Code is built with Claude models in mind. When it makes API calls, it uses model identifiers like claude-3-5-sonnet-20241022 or claude-3-opus-20240229—names that point specifically to Anthropic models. An aggregator that supports multiple providers uses its own alias system to identify models. To send Claude Code's requests to a different model, you need to understand how its hardcoded names are translated and how you can intercept or remap them.
How the aggregator handles model identifiers
The aggregator receives the model identifier from the client request and resolves it to a backend model. It supports aliases for many models, such as GPT, DeepSeek, Qwen, GLM, and Kimi. If the identifier matches a known alias, the aggregator routes the request to that model.
When Claude Code sends a Claude model name, the aggregator will typically map it to the corresponding Claude model if it is available. But this default behavior can be changed if you want to use a different model.
Intercepting and remapping model names
There are several ways to intercept Claude Code's model names and remap them to aggregator aliases:
- Environment variables: Claude Code may read model configuration from environment variables such as
ANTHROPIC_MODELor similar. Check the documentation for supported variables and set them to the aggregator alias of your desired model. - Proxy layer: Place a lightweight proxy between Claude Code and the aggregator. The proxy can inspect the request body, modify the
modelfield, and forward the request. This gives you full control over mapping logic. - Aggregator-side aliasing: Some aggregators let you define custom aliases that map a Claude model name to another backend model. If supported, configure an alias like
claude-3-5-sonnet→deepseek-chat. - Configuration files: Claude Code may have configuration files where you can override the model. Look for settings that accept a model name and set it to the aggregator alias.
Mapping examples
Suppose you want Claude Code to use DeepSeek instead of Claude. You could intercept the request and replace claude-3-5-sonnet-20241022 with deepseek-chat. Similarly, to use GPT, replace it with gpt-4o or the appropriate alias. Qwen models might use aliases like qwen-max. Always refer to the aggregator's model list for exact alias names.
Handling streaming and tool calls
Claude Code relies on streaming responses and structured tool calls. When remapping to a non-Claude model, ensure the target model supports the same API shape—streaming and tool/function calling. Most modern models on the aggregator do, but verify compatibility. If the target model has different capabilities, you may need to adjust the request format in your proxy.
Testing and validation
After setting up remapping, test with a simple request. Use a tool like curl to send a request through your proxy or with the modified environment variable and confirm the response comes from the intended model. Check response metadata if available to verify the backend model.
Considerations
- Remapping may break Claude Code features that depend on Claude-specific behaviors. Test thoroughly.
- Ensure your aggregator account has access to the target models.
- Keep your API key secure when using proxies.
By understanding how Claude Code's model names are translated and using interception techniques, you can direct its requests to a variety of models available on the aggregator, giving you flexibility and cost control.