Kimi Open Platform (Moonshot AI) now lets you point tools that were built for OpenAI-compatible and Anthropic-compatible endpoints directly at Kimi models, without writing your own proxy, translator, or thin compatibility shim. For teams already running Codex and Claude Code heavily, that means you can drop a strong, long-context, domestically hosted coding model into your existing agent workflows at a price far below US-frontier models. This is an executable SOP: the first half covers the base_url and model identifiers for the two integration paths, and the second half covers the configuration snippets, a minimal verification step, and a gotchas list. For why a cheap but capable coding model matters, see the flagship coding and reasoning model review; for the weights-open-sourcing angle, see Kimi K3 open weights.
1. Why wire Kimi into Codex and Claude Code
The appeal is not novelty. It is cost and context. Kimi's pricing sits well under the US-frontier bands (exact figures unconfirmed; see the Kimi pricing page), and kimi-k3 carries a 1M token context window that fits large repositories and long multi-document sessions without aggressive compaction. Claude Code and Codex are mature agent front ends with permission models, sub-agents, and file-editing loops that you have already tuned. Rather than rebuild that UX around a new SDK, the Open Platform lets you keep the tooling and swap only the model underneath.
This is the same "cheap strong model" thesis discussed in the flagship coding and reasoning model review, and it lines up with the broader "strong models get democratized" trend covered in Kimi K3 open weights. For a lightweight high-speed alternative on the low-cost branch, the Gemini 3.8 Flash hotspot is worth a parallel look.
Note that this is distinct from running your own OpenAI-compatible proxy: the platform endpoint handles translation, auth, and retries server-side, so there is no relay for you to operate and no extra latency hop that you introduced yourself. What you get is a directly usable dual-protocol compatibility layer, not a thin wrapper you have to maintain.
2. The two paths at a glance
Kimi Open Platform exposes two compatible endpoints, one per tool's underlying protocol:
- OpenAI Responses API path — for Codex. Codex's underlying calls are OpenAI-style Responses or Chat calls; point them at
https://api.moonshot.cn/v1and the platform translates to Kimi on the back end. - Anthropic Messages API path — for Claude Code. Claude Code's underlying calls are Anthropic-style Messages calls; point them at
https://api.moonshot.cn/anthropicand the platform emulates the Anthropic endpoint so Claude Code hits Kimi without knowing it.
These are not either-or. The same Kimi API key can feed both Codex and Claude Code at once, but the configuration lives in each tool's own config file. The table below aligns the objects:
| Tool | Protocol | base_url | Config file |
|---|---|---|---|
| Codex | OpenAI Responses API | https://api.moonshot.cn/v1 | ~/.codex/config.toml |
| Claude Code | Anthropic Messages API | https://api.moonshot.cn/anthropic | ~/.claude/settings.json |
3. Available models
The Kimi models reachable through these paths, and their context and behavior differences:
kimi-k3: the 1M-context long-context workhorse, good for large repos, long sessions, and multi-document retrieval.kimi-k2.7-code: 256K context, forced thinking, coding-specialized; it expands a reasoning chain before answering.kimi-k2.7-code-highspeed: the 256K high-speed variant, trading some quality for throughput, good for high-volume low-latency work.kimi-k2.6: the previous stable tier, useful as a fallback or control.
One subtlety: kimi-k2.7-code runs in forced-thinking mode, so every response first emits a reasoning chain and then the result. That is usually good for coding, but if you plan to call it as a pure completion endpoint at high frequency, budget for the extra latency and token cost of the thinking chain.
4. Step 1: get a Kimi API key
Go to the Moonshot Open Platform console and register, then create an API key. There is no proxy or relay here; the key is issued directly by the platform. Treat it as a secret: do not hardcode it in a repo, logs, or front-end code. Put the key in an environment variable or a secrets manager, and reference the variable name from the config files rather than pasting the plaintext into config.toml or settings.json.
If your team sits in a tiered quota plan, different keys have different ceilings. The exact tiers and your visible quota are shown in the console; this article does not invent numbers.
5. Step 2: wire Codex (Responses API)
Edit ~/.codex/config.toml to add your Kimi key and the wiring method. The two key lines are KIMI_API_KEY and wire_api = "responses". Here is a directly usable TOML block:
# ~/.codex/config.toml
[env]
KIMI_API_KEY = "sk-kimi-xxxxxxxxxxxxxxxx"
[model]
# Point at the Kimi Open Platform OpenAI-compatible endpoint
base_url = "https://api.moonshot.cn/v1"
# Use the Responses API wiring
wire_api = "responses"
# Model identifier
model = "kimi-k3"After saving, every underlying Codex request is rerouted to Kimi's Responses endpoint. Note that wire_api must be the string "responses"; a wrong type will silently fail to apply.
6. Step 3: wire Claude Code (Anthropic Messages API)
Edit ~/.claude/settings.json and write three variables into the env block: ANTHROPIC_BASE_URL points at Kimi's Anthropic-compatible endpoint, ANTHROPIC_AUTH_TOKEN holds your Kimi API key, and ANTHROPIC_MODEL is kimi-k3[1m]. Here is a directly usable JSON block:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.cn/anthropic",
"ANTHROPIC_AUTH_TOKEN": "sk-kimi-xxxxxxxxxxxxxxxx",
"ANTHROPIC_MODEL": "kimi-k3[1m]"
}
}The [1m] suffix is not decoration: it explicitly selects the 1M-context variant. If you write kimi-k3 without [1m], the platform may fall back to the default context window. Claude Code's UX (commands, permissions, sub-agents, file-editing interaction) is fully preserved; only the underlying model changes to Kimi.
7. Step 4: run a minimal verification first
Before pointing your whole agent workflow at Kimi, run one minimal call that depends on no tools and no long context: ask the model to echo a string verbatim. The goal is to confirm three things — the key is valid, the base_url is reachable, and the model identifier is parsed correctly. Any misconfiguration here will otherwise surface as a long series of "looks like it is running but silently failing" agent calls that are painful to debug.
Verification suggestion: use the simplest echo prompt and check that the response is exactly the input string; then try a slightly longer prompt to confirm the reply shape (thinking chain or plain answer) matches expectations. Only after the minimal check passes do you switch the full agent (with tools, multi-turn, long context) over. This matches the "verify small before scaling" discipline emphasized in the flagship coding and reasoning model review.
During the minimal check, watch for three failure shapes. First, an authentication error means the key is wrong or expired — confirm it was copied from the console and not a stale environment variable. Second, a connection error or 404 means the base_url is wrong for that tool's protocol; Codex must use the /v1 OpenAI path and Claude Code must use the /anthropic path, and swapping them is the single most common mistake. Third, a parse error on the model identifier (for example kimi-k3[1m] written with spaces, or a stray bracket) rejects before any completion is produced. At this step, log the raw HTTP status and the first error line from each tool; those two lines are almost always enough to localize the misconfiguration without escalating to a full agent run, where the same error would be buried under tool calls and retries.
8. Gotchas
- Responses API does not yet support video input. On the OpenAI Responses path, video input is currently out of scope. If your Codex task carries video frames or video files, confirm the platform has enabled it first, or fall back to another model or preprocess the video into text.
- Do not drop the
[1m]suffix. In the Claude Code path,ANTHROPIC_MODELmust carry[1m]to get the 1M context; omitting it falls back to the default window and silently truncates long-repo tasks. kimi-k2.7-codeforces thinking. It always runs a reasoning chain first, adding latency and token cost. For latency-sensitive high-frequency calls, considerkimi-k2.7-code-highspeed.- Key plaintext risk. Do not write the API key directly into files that get committed. Use environment variables or a secrets manager; keep only the reference in config.
- Quotas are tiered. Rate limits are tiered; the exact ceiling is shown in the console. Verify your tier before production traffic to avoid silent throttling.
- The two paths are independent. Codex and Claude Code configs do not affect each other; editing one does not sync the other, so check both during migration.
9. Cost and when it pays off
Kimi Open Platform pricing sits well below US-frontier models (exact rates unconfirmed; see the Kimi pricing page). For cost-sensitive workloads where the task is mostly coding and multi-document understanding, wiring Codex and Claude Code into Kimi can cut per-agent-call unit cost by roughly an order of magnitude while quality stays acceptable for most everyday coding tasks.
This echoes the "strong models get democratized" thread in Kimi K3 open weights and matches the conclusion in the flagship coding and reasoning model review about why a cheap strong coding model matters. As a parallel low-cost branch, the Gemini 3.8 Flash hotspot is also worth evaluating.
For production traffic, add a thin logging layer that records which model identifier actually served each request and the per-call token count. Because the Open Platform proxies the traffic, the responding model is Kimi even though the tool believes it called OpenAI or Anthropic, and your cost dashboards should reflect that rather than assuming a US-frontier bill. Pair that with a hard ceiling on daily spend so a misconfigured loop cannot run unnoticed; the tiered quotas make an unexpected bill more likely than a hard outage, and the cheapest model is also the one most tempting to leave running.
10. One-page cheat sheet
| Item | Codex path | Claude Code path |
|---|---|---|
| Protocol | OpenAI Responses API | Anthropic Messages API |
| base_url | https://api.moonshot.cn/v1 | https://api.moonshot.cn/anthropic |
| Config file | ~/.codex/config.toml | ~/.claude/settings.json |
| Key variables | KIMI_API_KEY, wire_api="responses" | ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL |
| Model id | kimi-k3 etc. | kimi-k3[1m] |
| Known limit | Responses API no video input yet | [1m] suffix sets context window |
References
- Kimi Open Platform (Moonshot AI) documentation: OpenAI-compatible endpoint
https://api.moonshot.cn/v1, Anthropic-compatible endpointhttps://api.moonshot.cn/anthropic, model identifiers (kimi-k3 / kimi-k2.7-code / kimi-k2.7-code-highspeed / kimi-k2.6),kimi-k2.7-codeforced thinking with 256K context, kimi-k3 1M context and the[1m]suffix convention. Exact doc URLs unconfirmed. - Kimi Open Platform console: API key issuance, tiered quota plans, rate-limit ceilings. Exact numbers shown in the console; this article does not confirm them.
- Kimi pricing page: unit pricing well below US-frontier models. Exact rates unconfirmed; see the official pricing page.
- Codex config conventions (
~/.codex/config.tomlenv/modelsections and thewire_apifield) and Claude Code config conventions (~/.claude/settings.jsonenvblock andANTHROPIC_*variable names) follow each tool's own configuration format; parameter names per the current tool version.
Frequently Asked Questions
Q1: Which configs change to wire Claude Code to Kimi?
A1: Only the env block in ~/.claude/settings.json changes, with three variables: set ANTHROPIC_BASE_URL to https://api.moonshot.cn/anthropic, set ANTHROPIC_AUTH_TOKEN to your Kimi API key, and set ANTHROPIC_MODEL to kimi-k3[1m]. Claude Code's interface, permissions, and sub-agents stay untouched; once saved, the underlying traffic goes to Kimi.
Q2: What are the base_urls for the Codex vs Claude Code paths?
A2: Codex uses the OpenAI Responses path with base_url https://api.moonshot.cn/v1; Claude Code uses the Anthropic Messages path with base_url https://api.moonshot.cn/anthropic. These are two distinct compatible endpoints the platform provides, mapped to each tool's underlying protocol; do not mix them up.
Q3: What does [1m] mean in kimi-k3[1m]?
A3: [1m] is a suffix on the model identifier that explicitly selects the 1M (one million token) context variant. If you write just kimi-k3 without the suffix, the platform may fall back to the default context window, and large-repo or long-session work will be silently truncated. Keep [1m] in the Claude Code path.
Q4: What are the current limits of the Responses API? A4: The main known limit is that the Responses API path (the OpenAI-compatible endpoint used by Codex) does not yet support video input. If your task carries video frames or files, confirm the platform has enabled that capability first, or fall back to another model or preprocess the video into text before sending. Other modalities and capabilities follow the platform docs.
Q5: How do I verify the integration works? A5: Run a minimal verification: use the simplest prompt asking the model to echo a string verbatim, confirming the key is valid, the base_url is reachable, and the model identifier is parsed correctly. Then try a slightly longer prompt to confirm the reply shape matches expectations. Only after the minimal check passes do you switch the full agent workflow (with tools and long context) to Kimi, avoiding a large silent failure on the first big task.