Large Language Models

Kimi K2 With Claude Code: API Setup, Pricing, Free Options, and Limits

Run Claude Code on Kimi K2 for a fraction of the usual bill. This article shows the exact environment variables, what a real coding session costs, which free routes still work, and the rate limits and errors that slow people down.

Kimi K2 With Claude Code: API Setup, Pricing, Free Options, and Limits
Cristian Da Conceicao

Claude Code is one of the best terminal coding agents around, and it has one obvious drawback: the bill. Moonshot AI's Kimi K2 family speaks the same protocol, so with three environment variables you can keep the Claude Code interface and swap the brain behind it for a model that costs a fraction as much per token. This article walks through the exact setup, what a realistic session costs, the free routes that still work, and the rate limits that catch people off guard. One note on facts: model IDs and prices in this space change almost monthly, and the figures below come from public listings and third-party trackers, so check Moonshot's console before you commit budget.

A developer typing into a terminal on a laptop in a bright co-working space

Why Pair Kimi K2 With Claude Code

What Claude Code Actually Does

Claude Code is a command line agent. You open it inside a project folder, describe a task, and it reads files, edits code, runs shell commands and loops until the job is done. The agent loop lives in the client. The model is just the engine that decides which tool call comes next.

That separation is the whole trick. Because the client only needs an endpoint that answers in a specific message format, any provider that mimics that format can power it.

Why Moonshot's Endpoint Works

Moonshot publishes an Anthropic-compatible endpoint next to its regular OpenAI-style one. Claude Code sends its usual requests, Moonshot translates them, and Kimi K2 answers with tool calls the client understands. No proxy, no wrapper script, no fork of the tool.

Kimi K2 is a mixture-of-experts model with roughly one trillion total parameters and a long context window, tuned heavily for agentic coding and tool use. That tuning is why it behaves well inside an agent loop instead of just chatting nicely.

💡 Quick note on availability: Kimi K2 itself is not on PicassoIA. If you want to try this model family in a chat window today, a later section covers close alternatives you can open right now.

API Setup in Five Minutes

Close-up of a mechanical keyboard with worn keycaps on a dark walnut desk

Step 1: Get a Moonshot Token

Create an account on Moonshot's developer platform, add a small balance, and generate an access token from the console. Treat it like a password. Anyone holding it can spend your balance.

Two regional platforms exist: an international one and a mainland China one. Tokens do not transfer between them, and each has its own base URL. Pick the one that matches where you registered.

Step 2: Set the Environment Variables

Claude Code reads its connection details from environment variables. On macOS or Linux, run this in the shell you will launch it from:

export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-moonshot-token"
export ANTHROPIC_MODEL="kimi-k2-thinking"
export ANTHROPIC_SMALL_FAST_MODEL="kimi-k2-thinking"

On Windows PowerShell, the same four settings look like this:

$env:ANTHROPIC_BASE_URL = "https://api.moonshot.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "your-moonshot-token"
$env:ANTHROPIC_MODEL = "kimi-k2-thinking"
$env:ANTHROPIC_SMALL_FAST_MODEL = "kimi-k2-thinking"

The small-and-fast variable matters more than people expect. Claude Code fires off cheap background calls for things like titles and summaries. If you leave that variable unset, those calls may still try to reach a model your new endpoint does not recognise, and you will see confusing errors.

Step 3: Launch and Verify

Start the agent inside a throwaway folder and ask something trivial, such as listing the files and describing the project. If the reply streams back and the session header shows the new model name, you are connected.

A quick sanity test I like: ask it to create a small script, run it, and fix any error it produces. That exercises file writes, shell execution and the tool-call loop in a single prompt.

Making It Permanent

Exporting variables every time gets old. Two cleaner options exist:

  • Shell profile: put the exports in your shell startup file, ideally behind a small function so you can switch between providers on demand.
  • Project settings: Claude Code supports an environment block in its settings file, which keeps the Moonshot configuration scoped to one repository instead of your whole machine.

💡 Tip: Never commit a settings file that contains the token. Add it to your ignore list before the first commit.

Which Model ID Should You Use

Two engineers at a whiteboard sketching boxes and arrows in a daylit office

Model names are the messiest part of this setup. Several guides disagree because Moonshot keeps shipping new releases. Public listings currently mention the original Kimi K2 instruct model, Kimi K2 Thinking and a Turbo variant, followed by the 2.5 and 2.6 releases and newer coding-tuned IDs. One tracker also reports that the oldest K2 endpoints reached end of life in late May 2026, so an ID that worked in a July tutorial may now return an error.

OptionBest forTrade-off
Kimi K2 ThinkingMulti-step refactors, debuggingSlower, more output tokens
Turbo variantSpeed on long sessionsHigher output rate in some listings
Kimi K2.5 / K2.6Newest behaviour, vision inputPrices differ by release
Original K2 instructCheap, fast editsMay be retired on some platforms

The practical rule: open the model list in Moonshot's console, copy the exact ID string, and paste it into the environment variable. Do not trust an ID from a blog post, including this one.

Kimi K2 Pricing Breakdown

Flat lay of a calculator, notepad with handwritten figures and a laptop on a wooden desk

Per-Token Rates

Prices are quoted per million tokens, split into input and output. Figures below come from third-party price trackers and should be treated as a snapshot, not a contract.

ModelInput per 1MOutput per 1MNotes
Kimi K2 Thinkingabout $0.60about $2.50Widely reported
Kimi K2 Thinking Turboabout $0.20 in some listingsabout $2.00Listings vary, verify
Kimi K2.6about $0.95about $4.00Cache hits about $0.16

Automatic prompt caching is the part that matters most for agents. Claude Code resends a large, mostly identical prefix on every turn: system instructions, tool definitions, and the growing conversation. When that prefix is served from cache, the input rate drops sharply.

The Real Cost of a Session

Take a busy afternoon of work: a refactor that burns about 500,000 input tokens across many turns and produces about 60,000 output tokens. Using the K2.6 rates above:

  • Without caching: 0.5M input at $0.95 is about $0.48, plus 0.06M output at $4.00 for about $0.24. Total near $0.72.
  • With 80% cache hits: 0.1M fresh input costs about $0.10, 0.4M cached input costs about $0.06, output stays at $0.24. Total near $0.40.

Either way you are in coin-flip territory compared with a premium frontier model, where the same session can run several times higher. The savings are real, though the quality gap is also real on the hardest tasks, which brings us to a fair comparison.

💡 Budget habit: set a low balance on your first day. Agents can loop, and a stuck loop is the fastest way to burn a month of credit in an hour.

Free Options That Actually Work

A young man on a sofa smiling at his laptop in a sunlit apartment

Let's be blunt: Moonshot's own API does not behave like a generous free tier. Public listings disagree on the details. Some say there is no free API access at all and you must recharge first, others describe a near-zero entry tier with very tight request limits. Plan on paying a few dollars at minimum.

Free Variants Through OpenRouter

OpenRouter has listed rate-limited free variants of Kimi K2 models. You need an account but, for the free models, no payment method. Expect daily request caps of a few hundred at best, and expect the free variants to be pulled or renamed without notice. They are fine for testing the setup, painful for a full workday.

OpenRouter exposes an Anthropic-style route too, so the same three environment variables work with a different base URL and token.

Free Tiers on Fast Inference Hosts

Groq has listed Kimi K2 instruct as free to use, with figures around 30 requests per minute and about 14,400 requests per day. That is plenty for light agent use. The catch is context: free tiers there often cap input size and tokens per minute, and a Claude Code session with a large repository can exceed that quickly.

Free Chat Access Instead

If your real goal is to try Kimi-style reasoning on a coding question rather than to run an agent, a chat window is free and simpler. Moonshot offers a consumer chat app, and a later section shows how to run similar models in PicassoIA with no token and no terminal.

Rate Limits and Hard Ceilings

Low-angle view of a quiet data center aisle with rows of black servers

How Moonshot Tiers Work

Limits on Moonshot's platform scale with cumulative recharge. Public summaries describe roughly:

TierCumulative rechargeApprox. concurrencyApprox. requests per minute
Entryabout $1very lowsingle digits
Tier 1about $10about 50about 200
Top tierabout $3,000about 1,000about 10,000

These numbers are community-reported, so read them as order of magnitude. The takeaway is simple: a first-day account with a small balance will hit request limits in a busy session, and topping up raises the ceiling.

Context Window Limits

Kimi K2 releases offer long context, with the newer ones reaching about 256K tokens. Claude Code tends to fill that more than you would guess, because file reads, command output and tool results all pile into the conversation. When it fills, the client compacts the history, and quality can dip after a compaction.

Why Agents Hit Limits Faster

A chat user sends one request every minute. An agent can send five in ten seconds, because every tool call is a new request. Parallel sub-tasks multiply this. If you see rate-limit errors on a plan that looks generous on paper, the burst pattern is the cause, not the daily total.

Common Errors and Fixes

A tired developer in a dark home office lit softly by a laptop and a warm desk lamp

Authentication Failures

A 401 almost always means a regional mismatch: an international token against the mainland base URL, or the reverse. Check where the account was created. Next most common: a stray space or newline pasted with the token.

Model Not Found

If the error names the model, the ID is wrong or retired. Copy it from the console again. Also confirm that the small-and-fast variable points to a valid ID, since that is the one people forget.

Tool Calls That Misbehave

Occasionally an open model produces a malformed tool call, and the client retries or stalls. Switching to the thinking variant usually helps for multi-step edits. For simple edits, shorter prompts with one clear goal produce cleaner tool use than a long wish list.

Slow First Responses

Thinking variants spend tokens reasoning before they act. That is expected. If a response feels stuck for more than a minute, interrupt and rephrase the task into smaller steps.

How to Get Similar Results on PicassoIA

A woman at a cafe window lit by her laptop screen on a rainy day

Kimi K2 is not on PicassoIA yet, and PicassoIA does not run Claude Code sessions. For similar results today in a browser, with no token and no billing setup, try these chat-ready models:

  • Kimi K2.6: the newest Kimi release here, with a 262K context window, vision input and native tool use.
  • Kimi K2 Thinking: step-by-step reasoning for debugging and design questions.
  • Claude Sonnet 5: a strong coding model if you want to compare against the Claude side of the pair.
  • DeepSeek V3.1: a cost-friendly option for code and reasoning.

Run a Coding Prompt With Kimi K2.6

  1. Open the Kimi K2.6 page.
  2. Paste the code or error you are stuck on into the Prompt box.
  3. Use the System Prompt to set the role, for example a senior engineer who answers with a short plan followed by a patch.
  4. Set Reasoning Effort to low or medium for quick edits, high for tricky debugging.
  5. Raise Max Tokens from the default of 2048 to 4096 or more when you expect a long answer or full file.
  6. Keep Temperature near 0.6 for code. Drop toward 0.2 when you want repeatable output.
  7. Attach a screenshot to Image Input when the problem is visual, such as a broken layout or a stack trace in a terminal window.

💡 Tip: to compare behaviour, paste the same prompt into Kimi K2.6 and Claude Sonnet 5 and read both answers side by side before deciding which one deserves your API budget.

Is It Worth the Switch

High-angle view of developers working at long wooden desks in a modern open-plan office

For most day-to-day work, yes. Routine refactors, test writing, small features and codebase questions all run well on a Kimi model inside Claude Code, at a cost that lets you stop watching the meter. The savings show up fastest on long sessions where caching kicks in.

For the hardest problems, such as subtle concurrency bugs or large architectural moves, a top-tier frontier model still tends to need fewer retries. A sensible setup keeps both: Kimi as the default for volume, and a premium model one environment switch away for the stubborn tasks.

If you wantChoose
Lowest cost per sessionKimi K2 Thinking via Moonshot with caching
Zero spend while testingOpenRouter or Groq free variants
Highest success on hard tasksA premium frontier model
A chat window, no setupPicassoIA language models

Try It Yourself on PicassoIA

You have seen how the pieces fit: three environment variables, a correct model ID, a small starting balance and realistic expectations about limits. Before you commit money to a terminal agent, test the models on your own code. Open Kimi K2.6, Kimi K2 Thinking or DeepSeek V3.1 on Picasso IA, paste a real bug, and compare the answers. When you are ready for more, browse every language, image and video model at picassoia.com/en/all-models and start experimenting.

Share this article

Choose your language

FreeCreate AI Images and VideosFree, No Credit CardFree Generations to StartSeedance 2.5 Lite IncludedStart Free Now