How to run Claude Code on open-source models
Claude Code talks to the Anthropic Messages API, so it runs on any open model served behind that API. Set ANTHROPIC_BASE_URL to https://api.theinferencecompany.si, ANTHROPIC_AUTH_TOKEN to your API key, and ANTHROPIC_MODEL to a model such as glm-5.3, kimi-k3 or deepseek-v4-pro. A typical coding task then costs $0.92 on GLM-5.3 instead of $1.96 on Claude Opus 5.5.
Set up
# In your shell, before starting Claude Code
export ANTHROPIC_BASE_URL="https://api.theinferencecompany.si"
export ANTHROPIC_AUTH_TOKEN="$TIC_API_KEY"
export ANTHROPIC_MODEL="glm-5.3"
claude
Claude Code now sends every request to the open model. Your prompts, tools, permissions and project settings stay the same. To switch back, unset the three variables.
Which model should Claude Code use?
- glm-5.3 for terminal-heavy work: 95.4% on SWE-bench Verified, at $0.92 per task.
- kimi-k3 for long sessions across a large repository: 1M-token context and the strongest on long coding loops, at $1.74.
- deepseek-v4-pro for the lowest cost at near-leading quality: $0.13 per task.
Claude Code also sends small background requests, such as titles and summaries. A cheap model like deepseek-v4.1-flash handles those well: set ANTHROPIC_DEFAULT_HAIKU_MODEL to it.
What changes, and what doesn't
Tool use, streaming and file edits work as before, because the API is the same. What changes is the model's behaviour: open models have their own strengths, and features tied to Anthropic's models, such as specific model names in your settings, need the new names. Run a few of your usual tasks before switching a whole team.
Other coding agents
OpenCode, Cline and any agent built on the OpenAI API connect the same way, through https://api.theinferencecompany.si/v1 with the model name of your choice. The cost comparison for each model is in the best open-source models for coding agents.
Common questions
Can Claude Code use open-source models?
Yes. Claude Code uses the Anthropic Messages API, so it runs on any open model served behind it. Set ANTHROPIC_BASE_URL to https://api.theinferencecompany.si, ANTHROPIC_AUTH_TOKEN to your API key and ANTHROPIC_MODEL to the model you want.
Which open-source model is best with Claude Code?
GLM-5.3 for terminal-heavy work, Kimi K3 for long sessions across a large repository, and DeepSeek V4 Pro for the lowest cost at near-leading quality.
How much does Claude Code cost on open-source models?
On a typical coding task, $0.92 on GLM-5.3 and $0.13 on DeepSeek V4 Pro, against $1.96 on Claude Opus 5.5.
More guides
- Open-source LLM inference for AI agents: the complete guide
- The best open-source models for coding agents in 2026
- How to fine-tune an open-source LLM for your AI agent
- Self-hosted LLMs vs an inference API vs on-prem: how to choose
- Prompt caching and the KV cache: why cached tokens decide an agent's bill
- Cost per successful task, explained