Setup guide - Documented by Kimi
Use Kimi in Codex CLI
Moonshot publishes a Codex guide. Kimi natively supports the Responses API, so you add a custom model provider in ~/.codex/config.toml with wire_api = "responses" and base_url https://api.moonshot.ai/v1, and Codex reads the key from KIMI_API_KEY. Codex's own advanced-config docs document the [model_providers.<id>] mechanism (base_url, env_key, wire_api).
Last verified 4 steps3 official sources
Steps
- Step 1.
Set the API key as an environment variable (macOS / Linux). Do not write the key into config.toml.
Terminalecho "Paste your Kimi API key and press Enter (input is hidden):" read -s KIMI_API_KEY export KIMI_API_KEY - Step 2.
Windows (PowerShell) equivalent.
Terminal$env:KIMI_API_KEY="YOUR_KIMI_API_KEY" - Step 3.
Open ~/.codex/config.toml (on Windows: %USERPROFILE%\.codex\config.toml) and add the following. If model or model_provider already exist, replace their values.
TOMLmodel = "kimi-k3" model_provider = "kimi" model_context_window = 1048576 [model_providers.kimi] name = "Kimi" base_url = "https://api.moonshot.ai/v1" env_key = "KIMI_API_KEY" wire_api = "responses" - Step 4.
Go to your project directory and start Codex. If Codex is already running, exit the session first so it reloads the configuration. Confirm Codex shows kimi-k3 as the current model, then send a simple request such as hello.
Terminalcd /path/to/your/project codex
Caveats
- The warning "Model metadata for kimi-k3 not found" is expected and does not affect usage. model_context_window = 1048576 makes Codex treat the context window as 1M.
- Codex CLI has no native video input channel. Video understanding needs a direct call to the Kimi API.
- A 404 on /v1/responses means base_url is wrong. It must be exactly https://api.moonshot.ai/v1.
- A 400 web_search.search_context_size is not supported error means the request included search_context_size. Remove it; Codex does not send it by default.
- The same config also applies to Codex Desktop, where the model picker may show Custom.
More setup guides
Same tool, other providers
Related reading
- Kimi K3 Is GA in GitHub Copilot: Pricing, Rollout, and What It Means for Model ChoiceKimi K3 is GA in GitHub Copilot at $3/$15 per million tokens, off by default for Business and Enterprise. Rollout details and what it means for model choice.
- Cloudflare Runs Kimi and GLM at Scale: FP8 KV Caches, INT4 Weights, and a Cache Safety NetCloudflare runs Kimi K2.6 and GLM 5.2 on Workers AI with FP8 KV caches, INT4 weights and a KV cache integrity check. What each technique buys on GPU fleets.
- AMD MI355X vs NVIDIA B200 vs B300 for Open-Weight ServingAMD MI355X vs NVIDIA B200 vs B300 for serving Kimi K3's about 1.5TB of open weights: verified specs, the Wafer benchmark, and cost per token for each.
- Kimi Linear: An Attention Architecture That Outperforms Full AttentionKimi Linear explained: Moonshot's KDA hybrid linear attention beat full attention with 75% less KV cache and up to 6x faster decoding at 1M context.
- Kimi K3 Weights Land on HuggingFace: 2.8T Open Frontier Model You Can Actually DownloadKimi K3 open weights are on HuggingFace: 2.8T parameters, 1M context, native MXFP4 and a ~1.63TB download. The specs, license terms and HN reaction.
- Kimi K3 in 10 Minutes: Moonshot AI's 2.8T Open Model, API Setup, Pricing, and BenchmarksKimi K3 from Moonshot AI is a 2.8T open model with a 1M-token context and an OpenAI-compatible API. How to call it, what it costs, and how it benchmarks.
FAQ
How do I use Kimi in Codex CLI?
Moonshot publishes a Codex guide. Kimi natively supports the Responses API, so you add a custom model provider in ~/.codex/config.toml with wire_api = "responses" and base_url https://api.moonshot.ai/v1, and Codex reads the key from KIMI_API_KEY. Codex's own advanced-config docs document the [model_providers.<id>] mechanism (base_url, env_key, wire_api).
Which Kimi model ids work in Codex CLI?
The official docs read for this guide list kimi-k3. Requests go to https://api.moonshot.ai/v1.
Is this an official Kimi and Codex CLI setup?
Kimi documents this setup in its own docs. It was last checked against 3 official pages on October 17, 2026.
Sources
Last verified against 3 official pages.
- platform.kimi.aihttps://platform.kimi.ai/docs/guide/codex-kimi.md
- developers.openai.comhttps://developers.openai.com/codex/config-advanced
- platform.kimi.aihttps://platform.kimi.ai/docs/models.md
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.