Skip to content
Aventail™ co-founder speaks to BBC Radio Wales on AI safety and AI agents.Read the story
Aventail™
All guides

Claude Code + Kimi: K3 setup, limits and where your code goes

14 min read

Run Claude Code on Moonshot's Kimi K3: the base URL and settings from Kimi's docs, the Kimi Code plan route, what breaks, where prompts go and the open weights.

Claude Code runs on Moonshot AI's Kimi models through Kimi's Anthropic-compatible endpoint at https://api.moonshot.ai/anthropic. Put that base URL, a Kimi API key and the Kimi model name in the env block of ~/.claude/settings.json, restart Claude Code, and every model request goes to Kimi.

As of 15 November 2026 the Kimi API Platform serves kimi-k3.1-pro, kimi-k3.1-pro-highspeed and kimi-k3, each with a 1M-token context window. The global platform is run by Moonshot AI Pte. Ltd. in Singapore and its privacy policy says data is stored on servers in Singapore. This guide gives the setup from Kimi's own docs, the separate Kimi Code plan route, how to check which model answered, what does not work, what the terms say about your prompts, the open weights, and the same setup for a team.

What you need

Value on 15 November 2026

Claude Code

Any current version. Native installer, or npm with Node.js 22 or later

Kimi account

An API key from the Kimi Platform console. A top-up of at least $1 is needed before the API works

Base URL

https://api.moonshot.ai/anthropic

Models

kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3

Context

1,048,576 tokens for every K3 series model

Billing

Pay-as-you-go per token, with no subscription on the API Platform. Rate limits rise with cumulative top-up

Older models

kimi-k2.7-code and kimi-k2.6 have been closed to newly registered accounts since the start of November 2026 and are due to be retired in late December 2026

Anthropic account

Not needed for model requests

Kimi sells coding access in two ways, and their keys are not interchangeable:

Kimi API Platform

Kimi Code

Where

platform.kimi.ai

kimi.com/code, with a Kimi membership

Billing

Pay-as-you-go

Subscription

Base URL for Claude Code

https://api.moonshot.ai/anthropic

https://api.kimi.ai/coding/

Credential variable

ANTHROPIC_AUTH_TOKEN

ANTHROPIC_API_KEY

Model name

kimi-k3[1m] in Kimi's example

k3.1-pro or k3.1-pro[1m], by plan

The steps below use the API Platform. The Kimi Code differences are in step 5.

Step 1: install Claude Code

macOS and Linux:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Or as a global npm package, which needs Node.js 22 or later:

npm install -g @anthropic-ai/claude-code

Step 2: clear old settings

If Claude Code was pointed at another provider before, stale values stay behind. Kimi's guide warns that the env block in ~/.claude/settings.json overrides variables exported in the terminal, so a leftover entry there can silently rewrite your model requests.

Before you configure Kimi:

  • Remove old ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_*_MODEL, CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_EFFORT_LEVEL entries from the env block. Kimi's page has a script that does this and leaves other settings alone.

  • Remove ANTHROPIC_* exports from ~/.zshrc and ~/.bashrc, or from user environment variables on Windows.

  • Remove ANTHROPIC_API_KEY in particular. It conflicts with ANTHROPIC_AUTH_TOKEN when both are present.

Step 3: create a Kimi API key

Create an API key in the Kimi Platform console and top up. The minimum is $1, and Kimi K3.1 Pro becomes available after a successful top-up. Create the key on the global platform, platform.kimi.ai. A key from the China platform or from Kimi Code does not work on this endpoint.

Step 4: configure Claude Code

Write these variables into the env field of ~/.claude/settings.json, then restart Claude Code. This is Kimi's published example, which sets every tier to kimi-k3[1m]:

{
"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": "1000000",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}

The file holds the key in plain text. Do not commit it.

Every line matters, because Claude Code uses different model tiers for the main conversation, background summaries and subagents. Kimi's reference table says what happens when one is missing:

Variable

If not configured

ANTHROPIC_BASE_URL

Requests go to Anthropic's endpoint and fail authentication

ANTHROPIC_AUTH_TOKEN

401 authentication errors

ANTHROPIC_MODEL

Model-not-found errors

The four ANTHROPIC_DEFAULT_*_MODEL variables

Tasks on that tier fail

CLAUDE_CODE_SUBAGENT_MODEL

Subagent tasks fail or degrade

CLAUDE_CODE_AUTO_COMPACT_WINDOW

Too small compacts early and loses context; too large causes context-length errors

CLAUDE_CODE_EFFORT_LEVEL

Lower values may reduce quality on complex tasks

The [1m] suffix tells Claude Code the model has a 1M-token window. Kimi's example uses kimi-k3, the previous flagship. The model list names kimi-k3.1-pro as the current flagship, and the check in step 6 calls it. Kimi's guide does not show that variant. To try it, put the model ID in the same variables and confirm with /status.

Step 5: or use a Kimi Code plan

Kimi Code is a subscription tied to a Kimi membership. Create the key in the Kimi Code Console and use Kimi Code's own endpoint and variable names. Kimi Code's page gives this for K3.1 Pro with the 1M window:

{
"env": {
"ANTHROPIC_BASE_URL": "https://api.kimi.ai/coding/",
"ANTHROPIC_API_KEY": "Your API Key",
"ANTHROPIC_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "k3.1-pro[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "k3.1-pro[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "k3.1-pro[1m]",
"CLAUDE_CODE_EFFORT_LEVEL": "high",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1048576",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1048576"
}
}

The context you get depends on the tier. On Plus and Moderato, k3.1-pro is capped at 262,144 tokens, so use k3.1-pro without the suffix and set both window variables to 262144. The 1M window needs Pro or Allegretto and above. The Go tier has no coding quota.

Step 6: check which model answered

Verify the endpoint and the key first. This is Kimi's own request:

curl https://api.moonshot.ai/anthropic/v1/messages \
--header "Authorization: Bearer $MOONSHOT_API_KEY" \
--header "Content-Type: application/json" \
--data '{"model": "kimi-k3.1-pro", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]}'

A normal JSON response means both work. A 401 means the key is invalid or belongs to a different platform. Then start Claude Code and enter /status:

  • Base URL should show https://api.moonshot.ai/anthropic.

  • Model should show kimi-k3[1m], or the model you set.

/model lists the models you configured. Send any message; a normal reply confirms the whole path.

Kimi also offers proof that a request reached its API. Send a random value in an X-Msh-Request-Nonce request header and the response carries Msh-Request-Timestamp and Msh-Request-Signature. Kimi's /v1/signatures/verify endpoint confirms that the Kimi API accepted that request for that model. It is meant for checking that a proxy has not substituted the model.

What works and what does not on Kimi

Works: chat, reading and editing files, running commands, the agent loop and subagents. Kimi's Messages API supports streaming, tool use, image input and thinking.

Does not work, or works differently:

  • Anthropic does not support it. Anthropic's documentation says it "doesn't support routing Claude Code to non-Claude models through any gateway".

  • K3 always reasons. Kimi's guide says K3 "always reasons and enables Preserved Thinking". Effort is set with CLAUDE_CODE_EFFORT_LEVEL, and while that variable is set, /effort in a session has no effect.

  • Cache markers inside messages are ignored. Kimi caches request prefixes automatically with a 5-minute lifetime. cache_control is read only at the top level of the request. On K3 models, cache writes are billed.

  • Missing variables fail silently. A tier that is not mapped asks for a Claude model name the Kimi endpoint does not recognise, and background tasks or subagents break.

  • A saved Claude login is bypassed. ANTHROPIC_AUTH_TOKEN takes precedence over a saved login. Run /status to see the active credential.

  • Claude.ai features are off. Connectors from claude.ai need a claude.ai login, and Remote Control is disabled whenever ANTHROPIC_BASE_URL points at a host other than api.anthropic.com.

  • Rate limits depend on spend. Concurrency, requests per minute and tokens per minute are set by the account's cumulative top-up tier.

  • K2 models are going. If an older guide sets kimi-k2.7-code or kimi-k2-turbo-preview, a new account cannot use it.

Where Kimi hosts the API and what it does with prompts

These are the statements in Moonshot AI's own documents, read on 15 November 2026. There are two platforms.

Question

Global platform (api.moonshot.ai)

China platform (api.moonshot.cn)

Who operates it

Moonshot AI Pte. Ltd., Singapore

Beijing Moonshot AI Technology Co., Ltd.

Where data is stored

"We store the information we collect in secure servers located in Singapore"

Personal information is stored in the People's Republic of China and is not provided overseas without separate consent

Governing law

Singapore, with arbitration at the Singapore International Arbitration Centre

Not read for this guide

Policy date

Privacy Policy 30 April 2025; Terms of Service 30 July 2026

Privacy policy effective 31 August 2026

For the global platform:

  • What is collected. "The prompts, audios, images, videos, files and other content that you input and generate". The policy says this information "helps us optimize our models".

  • Use for training. The Terms of Service say: "We may use Content to provide, maintain, develop, support, and improve the Services". A customer "who requires restrictions on the use of Customer Content for training or improving Moonshot AI models may contact Moonshot AI to discuss available enterprise arrangements". Without a written agreement, "Customer Content may be used for the foregoing purposes".

  • Retention. "Account, input, and payment information are retained while your account is active."

  • Confidentiality. The terms deem Customer Content to be the customer's Confidential Information.

  • Disclosure to authorities. Moonshot AI may share information to "comply with applicable law, legal process or government requests, as consistent with international standards".

The documents do not publish a zero-retention option or a fixed deletion period for API inputs. The Kimi Code subscription is a separate product under kimi.com terms, which we did not read for this guide.

The alternative: Kimi's open weights on your own hardware

Moonshot AI publishes Kimi weights on Hugging Face. Running them yourself means the Kimi API is not involved and the terms above do not apply to your prompts. The sizes below were read on 15 November 2026.

Model

Size on disk

Parameters

Licence

Kimi-K3.1-Pro

About 1,561 GB of weights

2.8T total, 104B active. 1M context

Kimi K3.1-Pro License: MIT-style. A model-as-a-service business above $20 million in annual revenue needs a separate agreement

Kimi-K3

About 1,561 GB of weights

2.8T total

Its own kimi-k3 licence

Kimi-K2.7-Code

595 GB of weights

1T total, 32B active. 256K context

Modified MIT

Kimi-K2.7-Code GGUF (unsloth, community build)

304 GB to 584 GB by quantisation

Same model

Not a Moonshot release

Moonshot recommends vLLM, SGLang or TokenSpeed for K3.1 Pro, and vLLM or SGLang for K2.7 Code. No Kimi model fits a laptop or a single workstation GPU: the smallest official release is 595 GB. This is a GPU-server project.

The Ollama library lists kimi-k3.1-pro, kimi-k3, kimi-k2.7-code and kimi-k2.6, all as :cloud models that run on Ollama's servers. None has a downloadable tag.

If you need a model that runs on a developer machine, pick one from our guide to Claude Code with Ollama. Once a Kimi model is served on your network through an Anthropic-compatible API, the Claude Code side is the same: change the base URL to your server and use the model name it serves.

The same models for a team with Aventail™ Connect

The steps above put a Kimi key in each developer's settings file. A security lead has no record of which machine sent which request where, and a developer can edit the file.

Aventail™ Connect configures Claude Code to send its model requests through Aventail™ Link, the inference engine and gateway that runs on each machine. Routing rules are set in Aventail™ Control and evaluated on the device. For open weights, the docs support this much:

  1. Serve a model where it fits. Link runs GGUF language models on the device. A larger model can sit on one internal server running Link and be named in a rule as a network peer. The peer must offer the exact model and have Serve other devices enabled. Peer routing is in beta.

  2. Connect Claude Code. In Link, open Connected apps and choose Connect next to Claude. There is no endpoint or key to enter. Claude Code needs at least 64K context.

  3. Write the rule. Permit only On device, or only the peer. If that destination is unavailable, the request fails with an error and is not sent elsewhere.

  4. Check the record. Send a harmless prompt and confirm the destination in Requests in Control.

Kimi's weights are far larger than any model in Aventail™'s published walkthroughs. Models this size need server hardware. Hardware and model scope for Aventail™ Link Server is agreed with Aventail™'s team, so talk to them before you plan around Kimi. Free covers three connected devices. Starter is £50 a month excluding VAT with ten devices included. Routing policies need Control for Enterprise.

Which path to take

Kimi API by hand

Kimi weights on your own servers

Open weights with Aventail™ Connect

Who it suits

One developer, non-sensitive code

An organisation with GPU servers and staff to run them

A team whose code must stay on approved machines

Setup

A settings file per developer

vLLM or SGLang, then a base URL per developer

Connect button in Link, rules in Control

Where prompts are processed

Moonshot AI's servers in Singapore

Your hardware

Where the routing rule says, evaluated on the device

Terms that cover your prompts

Moonshot AI's, under Singapore law

Your own

Your own

Record of requests

Kimi console, by project and key

Whatever your server logs

Requests view in Control

If the endpoint is down

Requests fail

Requests fail

Fails closed, or falls back to an approved destination

Cost

Per token, prepaid

Hardware and power

Free for three devices; £50 a month for ten

Frequently asked questions

Can I use Kimi in Claude Code?
Yes. Kimi's API has an Anthropic-compatible endpoint at https://api.moonshot.ai/anthropic. Set it as ANTHROPIC_BASE_URL with a Kimi API key in ANTHROPIC_AUTH_TOKEN and map every model tier to a Kimi model.

Which Kimi model should I use in Claude Code?
Kimi's guide uses kimi-k3[1m] for every tier. kimi-k3.1-pro is the current flagship. kimi-k2.7-code is closed to new accounts and due to be retired in late December 2026.

What is the difference between the Kimi API and Kimi Code?
The Kimi API Platform is pay-as-you-go and uses https://api.moonshot.ai/anthropic. Kimi Code is a subscription that uses https://api.kimi.ai/coding/ and its own keys. Kimi's docs say the two are independent and not interchangeable.

Why do I get a 401 error?
The key is invalid, or it was created on a different Kimi platform from the endpoint you set. A leftover ANTHROPIC_API_KEY also conflicts with ANTHROPIC_AUTH_TOKEN. Remove it.

Is my code sent to China when I use Kimi?
On the global platform, Moonshot AI's privacy policy says its servers are in Singapore and the operator is a Singapore company. The China platform, api.moonshot.cn, stores data in the People's Republic of China.

Does Moonshot AI train on API prompts?
Its terms allow it to use Content to develop and improve the services unless a separate written agreement says otherwise. Customers who need a training restriction are told to contact Moonshot AI.

Can I run Kimi locally with Claude Code?
Only on servers. The open weights range from 595 GB for Kimi-K2.7-Code to about 1,561 GB for Kimi-K3.1-Pro. The Kimi entries in the Ollama library are hosted cloud models.

Sources

  1. Kimi API Platform, Use Kimi in Claude Code: https://platform.kimi.ai/docs/guide/claude-code-kimi

  2. Kimi API Platform, API Overview: https://platform.kimi.ai/docs/api/overview

  3. Kimi API Platform, Messages API: https://platform.kimi.ai/docs/api/messages

  4. Kimi API Platform, Model List: https://platform.kimi.ai/docs/models

  5. Kimi API Platform, Model Inference Pricing: https://platform.kimi.ai/docs/pricing/chat

  6. Kimi API Platform, Recharge and Rate Limiting: https://platform.kimi.ai/docs/pricing/limits

  7. Kimi API Platform, Kimi K3.1 Pro quickstart: https://platform.kimi.ai/docs/guide/kimi-k3-1-pro-quickstart

  8. Kimi API Platform, Best Practices for context caching: https://platform.kimi.ai/docs/guide/context-caching

  9. Kimi API Platform, Verify Request Signature: https://platform.kimi.ai/docs/api/signatures-verify

  10. Kimi API Platform, Compare with Other Kimi Products: https://platform.kimi.ai/docs/guide/product-plans

  11. Kimi API Platform, Manage Your Organization in the Console: https://platform.kimi.ai/docs/guide/org-best-practice

  12. Kimi OpenPlatform Privacy Policy (30 April 2025): https://platform.kimi.ai/docs/agreement/userprivacy

  13. Terms of Service for Kimi OpenPlatform (30 July 2026): https://platform.kimi.ai/docs/agreement/modeluse

  14. Kimi Code, Claude Code: https://www.kimi.com/code/docs/en/third-party-tools/claude-code

  15. Kimi China platform, Claude Code guide and privacy policy (effective 31 August 2026): https://platform.kimi.com/docs/guide/claude-code-kimi and https://platform.kimi.com/docs/agreement/userprivacy

  16. Hugging Face, moonshotai: Kimi-K3.1-Pro, Kimi-K3, Kimi-K2.7-Code: https://huggingface.co/moonshotai

  17. Hugging Face, unsloth/Kimi-K2.7-Code-GGUF: https://huggingface.co/unsloth/Kimi-K2.7-Code-GGUF

  18. Ollama library: kimi-k3.1-pro, kimi-k3, kimi-k2.7-code, kimi-k2.6: https://ollama.com/search?q=kimi

  19. Anthropic, Claude Code setup: https://code.claude.com/docs/en/setup

  20. Anthropic, Claude Code environment variables: https://code.claude.com/docs/en/env-vars

  21. Anthropic, Model configuration: https://code.claude.com/docs/en/model-config

  22. Anthropic, Other LLM gateways: https://code.claude.com/docs/en/llm-gateway

  23. Anthropic, Feature availability: https://code.claude.com/docs/en/feature-availability

  24. Aventail™, Connect overview: https://docs.aventail.co.uk/docs/connect/overview

  25. Aventail™, Routing: https://docs.aventail.co.uk/docs/fleet/routing

  26. Aventail™, Compatibility and versions: https://docs.aventail.co.uk/docs/introduction/versions-and-supported-models

  27. Aventail™ Server: https://aventail.co.uk/inference-providers

  28. Aventail™, Pricing: https://aventail.co.uk/#pricing

All sources were read on 15 November 2026.

We use optional cookies and tracking to identify visiting companies, load our contact form, measure Google Ads download clicks and understand page use with PostHog on our homepage, Connect and How it works pages, Ollama and LM Studio comparison guides and campaign pages. Cookie policy