Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

  1. Step 1.

    Set the API key as an environment variable (macOS / Linux). Do not write the key into config.toml.

    Terminal
    echo "Paste your Kimi API key and press Enter (input is hidden):"
    read -s KIMI_API_KEY
    export KIMI_API_KEY
  2. Step 2.

    Windows (PowerShell) equivalent.

    Terminal
    $env:KIMI_API_KEY="YOUR_KIMI_API_KEY"
  3. 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.

    TOML
    model = "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"
  4. 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.

    Terminal
    cd /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.

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.

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.