# How to Connect Kimi K3 to Claude Code Without Breaking Your Setup > Canonical: https://www.yalc.ai/blog/connect-kimi-k3-to-claude-code/ Three environment variables, two gotchas, and one verification command get Claude Code running on Kimi K3 in under ten minutes. To connect Kimi K3 to Claude Code, set three environment variables: `ANTHROPIC_BASE_URL` to `https://api.moonshot.ai/anthropic`, `ANTHROPIC_AUTH_TOKEN` to your Moonshot API key, and `ANTHROPIC_MODEL` to `kimi-k3`. Kimi K3 exposes an Anthropic compatible endpoint, so Claude Code talks to it natively with no proxy or plugin required. That is the whole mechanism. Everything else in this guide is about doing it cleanly, avoiding the two failure modes that burn an afternoon, and knowing what actually changes once the swap is live. ## Why Connect Claude Code to Kimi K3 at All Claude Code is a harness. It handles tool calling, file editing, shell execution, and the agent loop. The model behind it is just an API target, and Kimi K3 presents an Anthropic compatible endpoint, which means Claude Code can use it without any modification, as documented in the [Kimi guide for using Kimi in Claude Code](https://platform.kimi.ai/docs/guide/claude-code-kimi). Three practical reasons to make the swap. First, price. Running Claude Code on K3 bills your Moonshot key at 3.00 dollars per million input tokens and 15.00 dollars per million output tokens, which [eesel AI's pricing breakdown](https://www.eesel.ai/blog/kimi-k3-pricing) puts at about 40 percent under Opus 4.8. If your team runs long agentic sessions all day, that delta compounds fast. Second, behavior. Per the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi), kimi-k3 thinks by default and works out of the box in Claude Code, so you get reasoning traces without extra flags or config. Third, optionality. Once you learn the env var pattern, the harness stops caring which lab made the model. That same pattern is why operators who use [Claude Code for sales workflows](/blog/claude-code-for-sales/) or [Claude Code for marketing teams](/blog/claude-code-for-marketing/) can experiment with backends without retraining anyone on a new tool. One honest caveat before you start: swapping the model changes the quality profile of every task Claude Code runs. Cheaper tokens do not help if your agent starts mangling multi file edits. Section seven covers how to verify on real work before you commit. ## The Setup, Step by Step The entire configuration is three environment variables, confirmed by both the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi) and the [Atlas Cloud third party API setup guide](https://www.atlascloud.ai/blog/guides/claude-code-third-party-api-setup). ### Step 1: Get your Kimi API key Sign in to [the Moonshot platform console](https://platform.moonshot.ai) and create an API key. This key is what Claude Code will present instead of an Anthropic key, and it is what gets billed. Treat it like any other secret. Do not paste it into a committed dotfile or a shared script. ### Step 2: Set the three variables In your shell, export the following, exactly: ```bash export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic" export ANTHROPIC_AUTH_TOKEN="sk-your-moonshot-key-here" export ANTHROPIC_MODEL="kimi-k3" ``` Three things to get right: - `ANTHROPIC_BASE_URL` must be `https://api.moonshot.ai/anthropic`, the Anthropic compatible path, not the default Moonshot API root. The [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi) are explicit about this path. - `ANTHROPIC_AUTH_TOKEN` holds your Kimi API key, per both the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi) and the [Atlas Cloud guide](https://www.atlascloud.ai/blog/guides/claude-code-third-party-api-setup). - `ANTHROPIC_MODEL` must be `kimi-k3`, the exact model id from the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi). Typos here fail silently into confusing errors. ### Step 3: Make them permanent Exports in a terminal die with the session. Add the same three lines to your shell profile, `.zshrc` on modern macOS or `.bashrc` on most Linux setups, then open a fresh terminal. Launch Claude Code from that terminal. If it was already running, quit and restart it, because it reads the environment at startup. ## Gotcha One: Remove ANTHROPIC_API_KEY This is the failure that wastes the most time, and the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi) call it out directly: if `ANTHROPIC_API_KEY` was set before, remove it, because it conflicts with `ANTHROPIC_AUTH_TOKEN` when both are present. The scenario is common. You used Claude Code with a direct Anthropic key months ago, dropped `ANTHROPIC_API_KEY` into your shell profile, and forgot about it. Now you add the Kimi variables, and the stale key is still sitting there. Two credential variables are live at once, and the client behavior is not what you want. The fix is unglamorous: ```bash unset ANTHROPIC_API_KEY ``` Then open your shell profile and delete or comment out the line that sets it. Restart your terminal, restart Claude Code, and continue. Check before you assume: run `env | grep ANTHROPIC` and look at what is actually set. You want to see exactly `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, and `ANTHROPIC_MODEL`, nothing else. Any fourth variable with an Anthropic prefix is a suspect. ## Gotcha Two: The /model Menu Will Not Show Kimi Operators hit this one within the first five minutes. They set everything correctly, open Claude Code, type `/model`, scan the list, see no Kimi entry, and conclude the setup failed. It did not fail. Per the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi), the `/model` menu is a fixed list of built in aliases, and it does not show Kimi. There is no toggle, no refresh, and no config file that adds it. Do not try to switch there; the env vars are what route the requests. The correct verification is `/status`. Run it inside Claude Code and check which model and base URL the session reports. If it shows `kimi-k3` against the Moonshot endpoint, you are done, regardless of what the menu says. This matters beyond cosmetics. Teams waste real time filing internal bug reports and re-running installs because the menu looks wrong. Write the `/status` check into your team readme the day you roll this out, next to whatever other setup notes you keep for tools like [the GitHub MCP integration](/mcps/github/), and save every future adopter the same confusion. ## The Proxy Route for More Than One Provider Direct env vars are the right answer when Claude Code should always run on K3. They are the wrong answer when you want to pick a backend per task, say K3 for bulk work and something else for a specific job. For that case, use a local Anthropic compatible proxy. The open source [claude-code-proxy on GitHub](https://github.com/raine/claude-code-proxy) sits between Claude Code and your providers, letting it reach a Kimi, ChatGPT, or Grok backend and choosing the upstream per request from `ANTHROPIC_MODEL`. The shape of the setup stays familiar. Claude Code points at the local proxy instead of at Moonshot directly, the proxy holds each provider's credentials, and the model name in each request decides where it lands. The tradeoff is real, so name it: you now own a local service. It has to be running, it is another thing to debug when a request fails, and it adds a hop between your client and the model. For a single user who always wants K3, the proxy is overhead with no payoff. For an operator benchmarking backends against each other on identical tasks, it is exactly the right tool, because it turns model comparison into changing one variable instead of juggling shell profiles. ## What Changes Once Claude Code Runs on K3 The swap is not free. Three things genuinely change, and you should verify each before standardizing on it. Billing moves to your Moonshot key. Nothing goes through Anthropic anymore. Usage bills at 3.00 dollars per million input and 15.00 per million output tokens, per [eesel AI](https://www.eesel.ai/blog/kimi-k3-pricing). Set a budget alert in the Moonshot console before your first heavy week, not after the first surprise invoice. Behavior differs. Per the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi), kimi-k3 thinks by default, which changes latency and token consumption patterns compared to what your team is used to. Tool use habits, verbosity, and error recovery style all shift with the model. None of that is automatically worse, but it is automatically different, and anyone who tells you a model swap is transparent has not run one in production. Verification has to happen on your tasks, not on a demo prompt. Pick three real jobs from last week, a refactor, a research task, a multi file change, and run them end to end on K3. Compare output quality and total token spend against what those jobs cost before. An afternoon of this tells you more than any benchmark table. If that exercise sounds familiar, it should. Swapping the model underneath a fixed harness is the same architectural bet behind [building your own GTM agent](/blog/building-your-own-gtm-agent/) instead of buying a monolith: the workflow, tools, and guardrails are the durable asset, and the model is a replaceable component. It is also the bet we made with Yalc, an [agentic GTM operating system](/blog/agentic-gtm-operating-system/) that runs conversational GTM agents on top of your existing CRM, sequencer, and data providers while staying model agnostic underneath. A rep asking an agent to work a lead list with [a lead qualification skill](/skills/qualify-leads/) and fresh company data from [Crustdata](/tools/crustdata/) should never have to care which LLM is answering, for the same reason your Claude Code session should not care whether K3 or something else is behind the base URL. If you have just proved to yourself that a model swap is three env vars, you already understand the entire philosophy. One more honest note: the teams that get burned here are the ones who standardize too early. Run the swap for two weeks on real work before you write it into onboarding docs. Models update, pricing moves, and the harness you keep is worth more than loyalty to any backend. That holds whether the workload is a coding session or [Claude Code for SDR teams](/blog/claude-code-for-sdrs/) running outbound research. ## FAQ ### How do I use Kimi K3 in Claude Code? Set three environment variables before launching Claude Code: `ANTHROPIC_BASE_URL` to `https://api.moonshot.ai/anthropic`, `ANTHROPIC_AUTH_TOKEN` to your Moonshot API key, and `ANTHROPIC_MODEL` to `kimi-k3`, per the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi). Restart your terminal and Claude Code, then confirm with `/status`. No plugin or fork is needed because K3 exposes an Anthropic compatible endpoint. ### What base URL and model does Claude Code need for Kimi K3? The base URL is `https://api.moonshot.ai/anthropic` and the model id is `kimi-k3`, as specified in the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi). Both values are exact; a wrong path or a typo in the model id will fail. Your Kimi API key from [the Moonshot console](https://platform.moonshot.ai) goes in `ANTHROPIC_AUTH_TOKEN`. ### Why does Kimi not appear in the Claude Code model menu? The `/model` menu is a fixed list of built in aliases and does not show Kimi, per the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi). This is expected, not a broken install. The environment variables route the requests, so verify the active model with `/status` instead of the menu. ### Do I need to remove ANTHROPIC_API_KEY? Yes. The [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi) state that `ANTHROPIC_API_KEY` conflicts with `ANTHROPIC_AUTH_TOKEN` when both are present. Unset it in your current shell and delete it from your shell profile, then restart Claude Code. Run `env | grep ANTHROPIC` to confirm only the three intended variables remain. ### Does Kimi K3 support thinking in Claude Code? Yes. According to the [Kimi docs](https://platform.kimi.ai/docs/guide/claude-code-kimi), kimi-k3 thinks by default and works out of the box in Claude Code, with no extra flags or configuration. Expect reasoning to affect both response latency and token usage, so factor that into your cost checks against the [published K3 pricing](https://www.eesel.ai/blog/kimi-k3-pricing).