Connect Codex to third-party models through Responses
Configure and probe Responses, check KimiSeek’s tool limits, then verify file reading, editing and multi-turn tool results. Includes 400 handling for unknown or invalid tools and upstream tool-policy errors.
The short answer
Current Codex supports only "responses" for wire_api. "chat" was removed and causes a startup configuration error. KimiSeek exposes /v1/responses; use the configuration below to check connectivity, and check tool support before running Codex tasks.
Tool support on KimiSeek
| Request capability | Service behavior |
|---|---|
Flat type: "function", function_call / function_call_output | Declarations, JSON/SSE calls and multi-turn history are supported; the client executes the tools |
custom (text / grammar), namespace, computer, local_shell / shell | Declarations are dropped, namespaces are not expanded, and they are not rewritten as functions; the request continues. Related history is dropped or downgraded and does not 400 the whole request |
web_search (including preview and dated versions), file_search, code_interpreter, image_generation, mcp | Optional declarations are omitted; the service does not execute these hosted tools or provide their results |
tool_choice pointing at a dropped tool, or tool_choice: "required" with no remaining function | Downgraded to auto; tool_choice is omitted when no functions remain. If a remaining function has the same name (for example a function named web_search), the forced function choice is kept. When functions remain, required still requires a function call |
| Invalid function definitions, unknown tool types, or a missing forced function | HTTP 400 before reservation, with no upstream call or charge |
Declarations of web_search, namespace and custom in a request are dropped and the request continues; that is not full support. Tasks that depend on apply_patch or namespaced file operations may not complete, because those tools are neither forwarded nor executed here. An HTTP 200 does not mean every Codex tool is available, and retrying the same request does not restore dropped tools.
30-second decision table
| Gateway capability | What to do |
|---|---|
Provides /v1/responses | Use "responses" |
Only /v1/chat/completions | Use a Responses-compatible gateway or a translation layer exposing Responses |
| Unknown | Probe the path and inspect the response body below |
Why Codex defaults to responses
Codex sends requests to /responses and consumes its tool-call and streaming events. Chat Completions uses different request and event structures; changing wire_api cannot make current Codex use it. Model capabilities also depend on the upstream and gateway implementation. A successful endpoint probe does not validate every tool capability.
Prerequisites
- Node.js 20 or newer
- Codex CLI:
npm install -g @openai/codex - A KimiSeek API key (starts with
ks-), created in the dashboard
Step 1 · Write the config file
Edit ~/.codex/config.toml (create it if it does not exist):
model = "deepseek-v4-pro-0813"
model_provider = "kimiseek"
[model_providers.kimiseek]
name = "KimiSeek"
base_url = "https://api.kimiseek.app/v1"
env_key = "KIMISEEK_API_KEY"
wire_api = "responses"Three things that trip people up:
base_urlmust include/v1. Codex appends/responsesdirectly tobase_url. Drop the/v1and the request goes tohttps://api.kimiseek.app/responses— a 404.env_keyis a variable name, not the key itself. You writeKIMISEEK_API_KEYhere; the actual value lives in your environment.modelmust be an id that really exists in the catalog. A typo returnsmodel not found, and so does a retired model id.
Step 2 · Set the environment variable and start
export KIMISEEK_API_KEY="ks-your-key"
codexTo switch models temporarily, edit model in config.toml or pass codex --model <id>.
Step 3 · List available models
# Public catalog; no API key required.
curl https://api.kimiseek.app/v1/modelsThis catalog is public and does not require an API key. A model list only confirms that the network and the catalog are reachable. To confirm that your key works, continue to the next step and call /v1/responses.
Step 4 · Probe responses in 30 seconds
curl https://api.kimiseek.app/v1/responses \
-H "Authorization: Bearer ${KIMISEEK_API_KEY:?Set KIMISEEK_API_KEY before running this command}" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro-0813",
"input": "Explain what a base URL is in one sentence.",
"max_output_tokens": 256,
"stream": false
}'- HTTP 200 with a JSON
outputarray → the Responses route works; next test a real task and tool calls. - HTTP 404 → check that
base_urlincludes/v1, then inspect whether the response reports a missing route or a missing model. The status alone is not enough. - HTTP 401 → return to Step 3 and check credentials.
Step 5 · Verify a real tool task
In a temporary repository, ask the client to create a file with a unique marker, read it, edit the marker, and read it again in the next turn. Confirm that calls reach the client, tools execute, results return in history, and the on-disk contents and final diff match the task. A plain-text HTTP 200 or an “edited” claim does not verify this. If the task depends on dropped custom / namespace tools, calls may never reach the client; use flat function tools or a provider that supports the original protocol. Invalid function definitions or a missing forced function still return 400 before reservation and are not billed. Retrying the same request does not restore dropped tools.
If the gateway only offers Chat Completions
Keep wire_api = "responses". Choose a gateway providing /v1/responses, or add a compatible translation layer. Do not switch to the removed "chat" value.
Common errors
| Error | Cause | Fix |
|---|---|---|
unexpected status 401 Unauthorized: Missing bearer | The variable named by env_key is unset or misspelled | Confirm KIMISEEK_API_KEY is visible in the current shell |
unexpected status 404 Not Found | base_url is missing /v1, or the gateway has no /v1/responses | Add /v1 and inspect the error body; if Responses is absent, use a compatible gateway or translation layer |
stream disconnected before completion | Network, timeout, or server/upstream protocol validation interrupted the stream | Check the error body and proxy or network; delivered content may be billed, so avoid blind retries |
upstream_tool_policy_violation | The upstream violated a function name, tool_choice, or parallel-call requirement | Check tool_choice and the model's tool support. JSON returns 502; SSE returns response.failed. With required or a specific function, content waits for validation; undelivered content is not billed |
model not found | Wrong model id, or a retired one | Use the full catalog id, e.g. deepseek-v4-pro-0813 |
More protocol-level errors are collected in the error reference.
Cost
Codex re-sends context each turn, so input often exceeds output. Current DeepSeek V4 Pro selling rates are shown below in CNY per million tokens, with their applicable tiers and effective conditions:
| Band | Input | Cached input | Output |
|---|---|---|---|
| Peak (01:00–04:00, 06:00–10:00 UTC (Beijing time 09:00–12:00, 14:00–18:00)) · Time bands from 2026-08-20 13:03:49.577 UTC; peak rates apply all day before then | ¥4.5 | ¥0.15 | ¥13.5 |
| Off-peak (outside 01:00–04:00, 06:00–10:00 UTC (Beijing time 09:00–12:00, 14:00–18:00)) · Time bands from 2026-08-20 13:03:49.577 UTC; peak rates apply all day before then | ¥2.25 | ¥0.075 | ¥6.75 |
Peak (01:00–04:00, 06:00–10:00 UTC (Beijing time 09:00–12:00, 14:00–18:00)) · Time bands from 2026-08-20 13:03:49.577 UTC; peak rates apply all day before then; Off-peak (outside 01:00–04:00, 06:00–10:00 UTC (Beijing time 09:00–12:00, 14:00–18:00)) · Time bands from 2026-08-20 13:03:49.577 UTC; peak rates apply all day before then
Time bands and rates come from the current catalog. Compare the same input range on the pricing page before scheduling work; off-peak is not guaranteed to be half-price or cheaper.
Versions and verification
Configuration checked with Codex CLI 0.154.0 on 2026-10-26. See the official configuration reference for protocol support.
FAQ
With a gateway like this, do I still need a bridge such as Codex-Bridge?
For supported flat function requests, KimiSeek exposes /v1/responses, so no route translation is needed. Declarations of custom / namespace / web_search are dropped and the request continues; that does not make those tools available. Tasks that depend on them still need a client mode that sends flat function tools, or a provider that supports the original protocol; an ordinary Responses-to-Chat bridge does not supply that capability automatically.
Why does base_url have to include /v1?
Codex concatenates: base_url + "/responses". Write https://api.kimiseek.app and the request goes to https://api.kimiseek.app/responses, which is a web page, not an API.
Can current Codex still use wire_api = "chat"?
No. Current versions reject that value at startup. Use responses; a Chat Completions-only upstream needs a compatible gateway or translation layer.
Can one key serve both Claude Code and Codex?
Yes. Keys are account-level; the clients simply call the same key over different protocol routes. See the Claude Code guide.