How to Use Kimi K3 and Ollama in Claude Code Paid vs Free Setup

DOWNLOAD THE CODE SNIPPETS USED VIDEO HERE:


How to Run Kimi K3 in Claude Code (And Add a Free Local Model with Ollama)

Short answer: Claude Code reads a settings file at ~/.claude/settings.json. Add a block of environment variables to that file pointing at Moonshot AI's Anthropic-compatible endpoint instead of Anthropic's own, and Claude Code runs on Kimi K3 instead of Claude. It is one file and a copy-paste. No coding background required.

This guide covers both halves of the swap: running Kimi K3 through the Moonshot API, and then pointing Claude Code at a completely free model running locally on your own machine with Ollama.


What Is Kimi K3?

Kimi K3 is Moonshot AI's open-weight large language model, with 2.8 trillion total parameters. Moonshot released the full weights on 27 July 2026 under a modified MIT licence, making it the largest open-weight model published to date. Open weight means the model files are downloadable rather than locked behind an API, so in principle you can run it yourself.

One clarification that matters, because the headline number is easy to misread: Kimi K3 is a sparse Mixture-of-Experts model. Of those 2.8 trillion parameters, only a small fraction — roughly 32 billion — are active on any given token. It is a 2.8T model in size, not in per-token compute. It also ships with a 1 million token context window, which is where the CLAUDE_CODE_AUTO_COMPACT_WINDOW value of 1048576 in the config below comes from.

The detail that matters most for this tutorial is that Moonshot exposes an Anthropic-compatible API endpoint. That is why Kimi K3 drops into Claude Code so cleanly. Claude Code does not need to be modified or patched. It just needs to be told a different address to send its requests to.

Model vs Harness: Why Swap the Engine, Not the Car

There are two separate things in play here, and keeping them separate is the whole idea.

  • The harness is Claude Code itself: the agent loop, the file editing, the tool use, the terminal integration, the permissions model.

  • The model is the thing actually doing the reasoning inside that harness.

Most people who want to try a different model go looking for a different app. You do not have to. Claude Code is one of the best harnesses available right now, and the model behind it is a configurable variable. Keep the car you already know how to drive and change the engine.

Can You Run Kimi K3 on Your Laptop?

No. It is worth being blunt about this because the phrase "open weight" leads a lot of people to assume otherwise.

The published weights are about 1.56 TB, spread across 96 shards on Hugging Face. Serving the model realistically means a multi-node cluster with 1.6 TB or more of aggregate GPU memory — published recipes start at 8 datacentre GPUs and scale to 64. Open weight means you are permitted to run it, not that you can run it on a MacBook.

So for Kimi K3 specifically you are using Moonshot's hosted API. In my experience around $20 in credits is enough to work through this comfortably and keep experimenting afterwards.

If what you actually want is something genuinely local and genuinely free, that is the Ollama half of this guide further down.

What You'll Need

  • Claude Code installed. If you don't have it: npm install -g @anthropic-ai/claude-code

  • A Moonshot AI account and an API key

  • Around $20 in Moonshot API credits

  • Ollama, for the free local model in Part 2

  • Any text editor

Step 1: Find the Hidden .claude Folder

Claude Code keeps its global configuration in a hidden folder in your home directory: ~/.claude. Hidden folders don't appear in Finder by default.

In Finder, press Cmd + Shift + . to reveal hidden files, or open the folder straight from the terminal. Inside, you are looking for settings.json. If it isn't there yet, create it.

The word global matters. Settings placed here apply to every project you open, rather than only the folder you happen to be working in.

Step 2: Create a Moonshot AI API Key

Head to the Kimi Open Platform console, open the API keys section, and create a key on the default project. Copy it immediately, because you generally cannot view it again after closing the dialog. Treat it exactly like a password.

Step 3: Edit settings.json to Switch Models

This is the actual swap. You are adding an env block that redirects where Claude Code sends its model requests.

{

  "env": {

    "ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",

    "ANTHROPIC_AUTH_TOKEN": "YOUR_MOONSHOT_API_KEY",

    "ANTHROPIC_MODEL": "kimi-k3[1m]",

    "ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3[1m]",

    "ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k3[1m]",

    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k3[1m]",

    "ANTHROPIC_DEFAULT_FABLE_MODEL": "kimi-k3[1m]",

    "CLAUDE_CODE_SUBAGENT_MODEL": "kimi-k3[1m]",

    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1048576",

    "CLAUDE_CODE_EFFORT_LEVEL": "max"

  }

}

Three things worth understanding rather than just pasting:

  • ANTHROPIC_BASE_URL is the redirect. This single line is what sends requests to Moonshot instead of Anthropic.

  • ANTHROPIC_AUTH_TOKEN holds your Moonshot key. If you previously set ANTHROPIC_API_KEY, remove it — having both present causes authentication conflicts.

  • The four ANTHROPIC_DEFAULT_*_MODEL variables and CLAUDE_CODE_SUBAGENT_MODEL exist because Claude Code uses different model tiers for different jobs. Set only some of them and things like background summarisation and sub-agents fail silently, which is maddening to debug.

Two cautions.  Values in settings.json override anything you export in your terminal, so stale entries here will quietly defeat a correct terminal setup. And this file stores your API key in plaintext — never commit it to a git repository. Restart Claude Code after saving.

Step 4: Verify Kimi K3 Is Running with /status

Start Claude Code, then type /status. You want to see:

Do not check the /model menu. It is a fixed list of built-in aliases and will never show Kimi models no matter how correct your config is. This trips people up constantly. /status is the source of truth.

Then send any message — a plain "hi" is fine. A normal reply confirms the setup works end to end.

Kimi K3 vs Claude Fable 5 vs GPT-5.6 on API Pricing

Kimi K3 comes in at roughly a third of Claude Fable 5's rate on both input and output. Against GPT-5.6 Sol it is around 40% cheaper on input and half the price on output. Kimi also prices cache hits at $0.30 per million input tokens, which matters more than it sounds — agentic coding re-sends the same context constantly, so a large share of your input tokens bill at the cached rate rather than the headline one.

That is the real argument for this swap. Claude Code is token-hungry by design, and on high-volume work the difference compounds fast. I walk through the comparison in the video at 6:32. Do check the live pricing pages before committing — these rates move quarterly.

Part 2: Run a Free Local Model with Ollama

Ollama runs models directly on your own machine. No API key, no per-token cost, and no data leaving your computer.

This got much simpler recently: from v0.14.0, Ollama exposes a native Anthropic Messages API endpoint. That means no translation proxy — no LiteLLM in the middle — just the same base-URL swap you did in Step 3.

Install Ollama from ollama.com/download, then pull a model. The default llama3.1 tag is the 8B version at about 4.9 GB, which is the right starting point for most laptops:

ollama pull llama3.1

Then point Claude Code at your local endpoint with the same env approach:

{

  "env": {

    "ANTHROPIC_BASE_URL": "http://localhost:11434",

    "ANTHROPIC_AUTH_TOKEN": "ollama",

    "ANTHROPIC_MODEL": "llama3.1"

  }

}

The auth token is a placeholder — Ollama does not check it, but Claude Code expects the field to exist. Verify with /status exactly as before. One practical constraint: run a model with at least a 32K context window, or Claude Code will struggle to hold a working session together. I walk through this on screen from 9:23 in the video, and the snippets are in the free folder below.

Where the Local Model Falls Short

Be realistic about this. Llama 3.1 running on a laptop is not a one-to-one replacement for Claude or for Kimi K3.

Smaller models are noticeably weaker at multi-step tool use, long-context reasoning, and holding a plan together across a large codebase — which happens to be exactly what Claude Code leans on hardest. Expect it to handle small, well-scoped edits and to struggle with anything ambitious.

Where it genuinely earns its place: working offline, keeping sensitive code on your own machine, and burning zero API budget on throwaway tasks. Treat it as a third gear, not a replacement. If you want to push further, Qwen is worth trying as a local coding model.

Frequently Asked Questions

How do I use Kimi K3 in Claude Code?

Add an env block to ~/.claude/settings.json that sets ANTHROPIC_BASE_URL to Moonshot's Anthropic-compatible endpoint, sets ANTHROPIC_AUTH_TOKEN to your Moonshot API key, and sets every model variable to kimi-k3[1m]. Restart Claude Code and confirm with /status.

Where is the .claude folder on Mac?

It's in your home directory at ~/.claude, hidden by default. Press Cmd + Shift + . in Finder to reveal it, or navigate there from the terminal.

Can Claude Code run a local model with Ollama?

Yes. Ollama v0.14.0 and later exposes a native Anthropic Messages API endpoint, so no proxy is needed. Install Ollama, pull a model such as Llama 3.1, then set ANTHROPIC_BASE_URL to http://localhost:11434 and ANTHROPIC_AUTH_TOKEN to any placeholder value. You get zero cost and full offline operation, at the price of noticeably weaker reasoning.

Can you run Kimi K3 on a laptop?

No. The model download alone is around 1.5 terabytes and it requires datacentre-class hardware. Open weight means the weights are published, not that consumer hardware can serve them. Use the Moonshot API for Kimi K3, and Ollama with a small model if you need something local.

Is Kimi K3 cheaper than Claude Fable 5 or GPT-5.6?

Yes, substantially. As of August 2026 Kimi K3 lists at $3 per million input tokens and $15 per million output tokens, against $10/$50 for Claude Fable 5 and $5/$30 for GPT-5.6 Sol. Cached input on Kimi K3 drops to $0.30 per million, which matters a great deal for agentic coding where the same context is re-sent repeatedly. Rates change often, so check the live pricing pages before committing.

How do I check which model Claude Code is using?

Run /status inside Claude Code. It reports the active base URL and model. The /model menu only lists built-in aliases and will not reflect a custom endpoint, so it is not a reliable check.

Next
Next

Claude + Higgsfield / heygen + Blotato: Faceless Reels on Autopilot