How to use Claude Sonnet 4.6 in Claude Code
Claude Code is Anthropic's terminal-native coding agent: it reads your repo, runs commands, edits files, and iterates until a task is done. Claude Sonnet 4.6 is the model most people want behind it — fast, strong at long agentic sessions, and cheaper than the Opus tier for everyday work. This guide shows how to run Sonnet 4.6 in Claude Code through AnyModel, so you get one billing relationship and the freedom to swap models without touching config.
Why route Claude Code through AnyModel
AnyModel is a single OpenAI-compatible endpoint. The base URL is https://anymodel.org/v1, and one API key reaches every model we host — Claude, GPT, Gemini, DeepSeek, GLM, Kimi, Qwen, and Grok. There's no separate Anthropic account, no per-provider key juggling, and switching models means changing one string: the model id. Nothing else in your setup moves.
That matters in Claude Code specifically, because you'll often want Sonnet 4.6 for the bulk of a session and a different model for a one-off task. With AnyModel you don't re-authenticate or re-install — you point at a new model id and keep going. Browse what's available on the models page.
The one-line install
The fastest path is our installer. It writes the right environment configuration for Claude Code and wires in your key:
bash <(curl -fsSL "https://anymodel.org/i?tool=claude") <YOUR_API_KEY>
Replace <YOUR_API_KEY> with the key from your dashboard. The tool=claude flag targets Claude Code; the same installer also supports codex, opencode, and hermes if you use those. After it finishes, launch Claude Code as you normally would and it will talk to AnyModel instead of the default endpoint.
If you prefer to configure things yourself, point Claude Code at the OpenAI-compatible base URL https://anymodel.org/v1 with your API key. That same manual pattern is what you'd use for other clients we don't have a one-liner for — Cursor, Windsurf, Zed, Cline, Aider, Continue, or Gemini CLI all accept a custom base URL plus key.
Selecting Claude Sonnet 4.6
Once installed, you select the model the way you always do in Claude Code, but the value you choose is the AnyModel model id for Sonnet 4.6. Two ways to set it:
- In-session: use Claude Code's model command/picker and choose the Sonnet 4.6 id.
- Persistent: set it as your default model id so every new session starts on Sonnet 4.6.
The exact id string is listed on the models page — copy it directly so there are no typos. To compare Sonnet 4.6 against Opus-class or other vendors' coding models on price and behavior, the compare tool lays them side by side.
Switching models mid-project
Say a refactor needs a second opinion, or you want a cheaper model for boilerplate. Change the model id and continue — your key, base URL, and project context stay put. This is the single biggest practical win of a unified gateway: model choice becomes a per-task decision, not an account migration.
What it costs to start
You can try all of this without a credit card. New accounts get 1,000,000 free tokens, rising to a total of 6,000,000 if you link Telegram. After the free tokens, it's pay-per-token — no subscription, no monthly minimums, no commitment. For an agent like Claude Code that can burn through context quickly on large repos, paying only for what you use tends to be friendlier than a flat plan.
A note on privacy
If your code is sensitive, enable Ghost Mode. It's opt-in zero-retention: your prompts and responses aren't stored on our side — only a token counter runs for billing. To be honest about the limits, this is not "100% privacy," because the underlying model provider still receives the prompt to generate a response. Ghost Mode removes our retention, which is the part we control.
Quick recap
| Step | Action |
|---|---|
| Install | bash <(curl -fsSL "https://anymodel.org/i?tool=claude") <YOUR_API_KEY> |
| Endpoint (manual) | base_url https://anymodel.org/v1 + your key |
| Pick model | Set Claude Code's model to the Sonnet 4.6 id from /models |
| Switch later | Change the model id — nothing else |
Want more setup walkthroughs and model comparisons? The blog has them.
Ready to code with Sonnet 4.6? Create your free AnyModel account and start with a million tokens — no card required.
AnyModel