Skip to content

Using Kimi in Codex

Codex is OpenAI's coding agent. This guide shows how to connect Codex CLI to Kimi For Coding via CC Switch, with Kimi K3 or Kimi K2.7 Code providing the model inference.

Community third-party integration, for reference only

CC Switch + Codex is a community-provided third-party integration, and this guide is for reference only. It is not officially maintained or supported, and we cannot guarantee its compatibility with every version of Codex / CC Switch. If you run into API compatibility issues, please troubleshoot and adapt based on your actual environment — and you are welcome to share your solution with the community.

Codex CLI currently supports text and image input, but does not provide a native video input channel — you cannot submit a video file directly as multimodal input to the model. To analyze video, extract key frames with ffmpeg and optionally combine with audio transcription before handing them to the model. This is a limitation of Codex CLI's input layer, not of the Kimi K3 model — the Kimi K3 API natively supports video input.

Membership

Before configuring, check your membership tier and pick the models and context-window values that match your plan:

TierAvailable modelsContext window
Andantekimi-for-coding256K
Moderatok3
kimi-for-coding
k3: 256K
kimi-for-coding: 256K
Allegretto and abovek3
kimi-for-coding
kimi-for-coding-highspeed
k3: up to 1M
kimi-for-coding: 256K
kimi-for-coding-highspeed: 256K

See Model configuration for model capabilities and setup details.

How it works

Codex CLI uses the OpenAI Responses API, while Kimi For Coding provides an OpenAI-compatible Chat Completions API. The two protocols are incompatible, so a local routing layer is needed to translate requests and streaming responses in both directions:

text
Codex CLI → CC Switch (local router) → Kimi For Coding API

The steps below use CC Switch as an example. Keep CC Switch and Codex routing running while using the Kimi For Coding provider.

Prerequisites

Before you start:

  1. Follow the official Codex documentation to install Codex CLI and start it at least once.
  2. Create and save an API Key in the Kimi Code Console.
  3. Follow the official CC Switch guide to install the version for your operating system.

WARNING

CC Switch is a third-party open-source tool and is not maintained by Kimi. Evaluate it against your organization's security and compliance requirements before use; your API Key and Codex requests and responses will be processed by its local router.

After installation, open CC Switch and follow the steps below.

Step 1: Enable Codex routing

In CC Switch, go to Settings > Routing:

  1. Turn on the Routing Master Switch to start the local routing service.
  2. Under Routing Enabled, turn on Codex.

Turn on the Routing Master Switch and Codex routing

Step 2: Add the Kimi For Coding provider

  1. Return to the CC Switch home screen and select the Codex tab at the top.
  2. Click + in the upper-right corner to add a provider.

CC Switch home screen — click + to add a provider

  1. Confirm you are on the Codex Provider page, then select Kimi For Coding from the preset provider list.

Select Kimi For Coding from the preset provider list

  1. Fill in the following settings:
SettingValue
API request URL (Base URL)https://api.kimi.com/coding/v1
API KeyAPI Key created in the Kimi Code Console

Fill in the API Key and API request URL

  1. Scroll down to Model Mapping and click Fetch Models — CC Switch will pull the three models Kimi For Coding currently supports. Then fill in each model's Menu display name and Context window using the table below:
Menu display name (suggested)Actual request modelContext window
K3k31048576 (use 262144 without 1M access)
K2.7 Codekimi-for-coding262144
K2.7 Code HighSpeedkimi-for-coding-highspeed262144

Also confirm the following advanced settings:

SettingValue
Upstream formatChat Completions (routing required)
Prompt cache routingAuto (recommended)
Supports thinking modeOn (must be on — turning it off routes K3 and K2.7 Code to K2.6)
Supports reasoning effortOn
  1. After confirming the settings, click Add in the lower-right corner.

Advanced settings — upstream format, reasoning capability, model mapping

Step 3: Enable the Kimi For Coding provider

Return to the Codex provider list and click Enable on the Kimi For Coding provider you just added.

Enable the Kimi For Coding provider in the Codex provider list

Confirm that:

  • Kimi For Coding is the active provider under the Codex tab;
  • CC Switch Local Routing is running;
  • Codex is enabled under the routing settings.

Step 4: Start Codex CLI

If Codex CLI is already running, exit the current session. Then enter the project directory where you want to work and start Codex CLI again:

bash
cd /path/to/your/project
codex

Restarting allows Codex CLI to load the latest provider and model configuration written by CC Switch.

After startup, confirm that Codex CLI shows k3 as the current model, then send a simple request:

text
hello

If Codex CLI returns a response and the status bar shows k3, the configuration is working.

Verify k3 in Codex CLI

You can also check the CC Switch routing counter or request logs to confirm a new Codex request has appeared.

Switching reasoning effort

K3 supports three reasoning effort levels: low / high / max. In a Codex CLI session, type /model to reselect the current model, then pick a level in the Select Reasoning Level menu:

Select Reasoning Level in Codex CLI

The levels Codex shows are mapped to K3's actual effort as follows (full mapping rules in Model configuration):

Codex Reasoning LevelK3 actual effort
Lowlow
Medium (default)high (recommended)
Highhigh (recommended)
Extra highmax

After switching levels, start a new session to avoid cache-invalidation overhead from the previous context.

FAQ

Codex still uses the original model after launch

CC Switch's config was not applied, or Codex CLI was not restarted. Exit the current Codex session and restart it, and confirm CC Switch local routing is running.

Cannot connect to the local router

CC Switch is not running, or Codex routing is not enabled. Launch CC Switch and check both the master switch and the Codex switch under Settings > Routing.

401 authentication error

The API Key is missing, expired, or your plan lacks permission. Regenerate the API Key in the Kimi Code Console, and confirm your plan supports the selected model (see the Membership table above).

Request format or streaming errors

The upstream format is not set to Chat Completions, or routing is not enabled. In the provider's advanced settings, confirm Upstream format is Chat Completions (routing required).

Model parameter errors

Kimi models have fixed sampling requirements. Do not override temperature, top_p, n, etc. in CC Switch.

Next steps