Field SOP
Field SOP

Wiring Kimi Open Platform into Codex and Claude Code

Kimi Open Platform (Moonshot AI) now lets OpenAI/Anthropic-compatible tools point natively at Kimi, with no self-built proxy. Two paths: ① OpenAI Responses API for Codex — base_url=https://api.moonshot.cn/v1, with KIMI_API_KEY and wire_api="responses" in ~/.codex/config.toml; ② Anthropic Messages API for Claude Code — base_url=https://api.moonshot.cn/anthropic, with ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN=Kimi Key / ANTHROPIC_MODEL=kimi-k3[1m] (the [1m] selects 1M context) in the env block of ~/.claude/settings.json. Models: kimi-k3(1M) / kimi-k2.7-code(256K forced thinking) / kimi-k2.7-code-highspeed / kimi-k2.6. The Responses API does not yet support video. This SOP gives directly usable config snippets, a minimal verification step, and six gotchas (including never dropping [1m], kimi-k2.7-code's forced thinking, and tiered quotas). Rate limits are tiered; exact numbers are per the console.

Published September 1, 202610 min read
<!-- kimi-openplatform-codex-claude-code-sop | sop | Wiring Kimi Open Platform into Codex and Claude Code -->

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:

  1. OpenAI Responses API path — for Codex. Codex's underlying calls are OpenAI-style Responses or Chat calls; point them at https://api.moonshot.cn/v1 and the platform translates to Kimi on the back end.
  2. Anthropic Messages API path — for Claude Code. Claude Code's underlying calls are Anthropic-style Messages calls; point them at https://api.moonshot.cn/anthropic and 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:

ToolProtocolbase_urlConfig file
CodexOpenAI Responses APIhttps://api.moonshot.cn/v1~/.codex/config.toml
Claude CodeAnthropic Messages APIhttps://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:

toml
# ~/.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:

json
{
  "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

  1. 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.
  2. Do not drop the [1m] suffix. In the Claude Code path, ANTHROPIC_MODEL must carry [1m] to get the 1M context; omitting it falls back to the default window and silently truncates long-repo tasks.
  3. kimi-k2.7-code forces thinking. It always runs a reasoning chain first, adding latency and token cost. For latency-sensitive high-frequency calls, consider kimi-k2.7-code-highspeed.
  4. 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.
  5. 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.
  6. 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

ItemCodex pathClaude Code path
ProtocolOpenAI Responses APIAnthropic Messages API
base_urlhttps://api.moonshot.cn/v1https://api.moonshot.cn/anthropic
Config file~/.codex/config.toml~/.claude/settings.json
Key variablesKIMI_API_KEY, wire_api="responses"ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL
Model idkimi-k3 etc.kimi-k3[1m]
Known limitResponses 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 endpoint https://api.moonshot.cn/anthropic, model identifiers (kimi-k3 / kimi-k2.7-code / kimi-k2.7-code-highspeed / kimi-k2.6), kimi-k2.7-code forced 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.toml env/model sections and the wire_api field) and Claude Code config conventions (~/.claude/settings.json env block and ANTHROPIC_* 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.

This article is AI-assisted and human-edited. Last updated: 2026-09-01

FAQ

Which configs change to wire Claude Code to Kimi?
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.
What are the base_urls for the Codex vs Claude Code paths?
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.
What does [1m] mean in kimi-k3[1m]?
`[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.
What are the current limits of the Responses API?
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.
How do I verify the integration works?
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.

Related

Field SOP

Qoder Free Credits Claim and Usage Management SOP

A hands-on SOP for claiming and managing Qoder's double promo: download and install (international qoder.com or China qoder.cn, across desktop, mobile, IDE, JetBrains plugin and CLI), sign up (the two editions keep separate accounts and quotas), confirm the free window works (selecting Qwen3.8-Flash in the model picker bills at a 0x coefficient, nothing to claim), then the daily 100 Credits rhythm (opens 10:00 daily, one claim per cycle, no carryover of missed days, each grant valid 30 days and stackable), usage management (check burn in the usage panel, let Qwen3.8-Flash carry routine work and save Credits for hard tasks), deduction rules (earliest-expiring credits are consumed first, in-plan before add-on packs on the same day), and a closing plan for when the window ends on September 30. UI details follow the actual client.

Sep 18, 20268 min read
Field SOP

Octop Self-Hosted AI Assistant Deployment SOP

A hands-on SOP for deploying Octop: it starts with a decision framework on whether to self-host at all, then walks four install paths (one-line script, Windows PowerShell, Docker Compose, and the Tencent Cloud Lighthouse or CVM official image marketplace), runs octop init and octop run verbatim from the official README (default port 8088), changes default credentials on first login (the README hardcodes none, third-party reviews report admin/octop, and Docker init generates a random one), then configures models (OpenAI-compatible, Ollama, nearly 20 providers), experts with MBTI personas, connectors (Tencent Docs, OAuth, MCP) and IM channels, and closes with Docker Compose and PostgreSQL productionization plus a six-item pitfall table and a ten-item pre-launch checklist.

Sep 17, 20268 min read
Field SOP

Intern-S2 in practice: from free API to scientific workflows

A hands-on SOP for accessing Intern-S2: for individuals and small teams the realistic path is the free API (chat.intern-ai.org.cn for online use, internlm.intern-ai.org.cn/api/strategy for quota), while institutions with compute can run the HuggingFace weights at internlm/Intern-S2-397B. It gives a three-way access comparison table, a minimal runnable Python call for the free API, an HF inference skeleton, two copy-paste prompt templates for scientific long-horizon tasks (molecule binder design, materials structure generation), plus Memory Decoder mounting notes and a ten-item pitfall list (free-tier rate limits, 397B out-of-memory, long-context truncation, the Preview model's 2026-10-31 shutdown and migration). Bottom line: start free on the API, do not jump straight to self-hosting a 397B model.

Sep 17, 202611 min read