Use Inference APIs with Codex CLI
Run OpenAI's Codex CLI on DeepSeek, GLM, Kimi or GPT-OSS with pay-as-you-go billing. Codex speaks the Responses API; this endpoint implements it for every chat model.
Settings
| Setting | Value |
|---|---|
| Base URL | https://api.inferenceapis.com/v1 (also /openai/v1) |
| API key | From API Keys; send as Authorization: Bearer … |
| Chat model ids | openai/gpt-oss-120b, deepseek-ai/DeepSeek-V4-Flash, zai-org/GLM-5.3-Flash, meta-llama/Llama-3.3-70B-Instruct-Turbo — all models |
| Audio model ids | openai/whisper-large-v3 (transcription), hexgrad/Kokoro-82M (speech) |
Which model
For real coding work use a large model: zai-org/GLM-5.3, deepseek-ai/DeepSeek-V4-Pro or moonshotai/Kimi-K2.7-Code. deepseek-ai/DeepSeek-V4-Flash is the cheap option for small edits. Prices and measured speed: chat models.
Configuration
model = "zai-org/GLM-5.3"
model_provider = "inferenceapis"
# model_reasoning_effort = "minimal" # switches thinking off; quicker and cheaper for small edits
[model_providers.inferenceapis]
name = "Inference APIs"
base_url = "https://api.inferenceapis.com/v1"
env_key = "INFERENCE_API_KEY"
wire_api = "responses"export INFERENCE_API_KEY="your-key"
codex # interactive
codex exec "add type hints to utils.py" # one-off task
codex -m deepseek-ai/DeepSeek-V4-Flash "..." # pick another model for one runVerify
codex exec --skip-git-repo-check "Reply with the single word: ready" < /dev/nullHow this guide was checked
Run end to end codex-cli 0.154.0: codex exec wrote a Python script, ran it and reported the output, through wire_api = "responses" on this endpoint, with DeepSeek V4 Flash, DeepSeek V4 Pro, GLM 5.3, GLM 5.3 Flash, MiniMax M3, Kimi K2.7 Code and GPT-OSS 120B, on 2026-09-17.
Gotchas
- Codex prints "Model metadata not found" for models it does not know. It is a warning about context-size defaults, not an error.
- Codex keeps the conversation on its side and resends it each turn, which is what this endpoint expects. Stored responses (previous_response_id) are not supported.
- Codex's built-in web search tool is an OpenAI-hosted tool and is dropped; function tools such as the shell and apply_patch work.
- A typical small task used 6,000 to 7,000 tokens in our test, most of it Codex's own system prompt. After the first turn that prompt is served from cache and billed at the cached-input rate, about 80 to 98 percent lower, so a session costs far less than the raw token count suggests.
- Some of these models think for many seconds before acting. Set model_reasoning_effort = "minimal" to switch thinking off for routine edits; leave it on for hard problems.
- GPT-OSS 120B sometimes calls a tool Codex did not offer and has to recover, which costs extra turns. The larger models were steadier in our runs.
If something fails
401 — key missing or wrong · 402 insufficient_balance — add credits on Billing · 404 model_not_found — check the id against the model list (aliases such as gpt-oss-120b work too) · 503 model_unavailable — the model is being enabled. Full details in the API docs.
