Codex CLI
Run codex against your own endpoint (vLLM, llama.cpp, Ollama, a LiteLLM or llama-swap gateway) with a custom model provider, a safe key setup, correct limits and a verified Responses endpoint.
Scope: the Codex CLI and its config.toml. Gateways and engines belong to their own skills. Codex custom providers speak only the Responses API; there is no Chat Completions mode.
Work through the steps in order. Load a reference only when a step names it.
Discover first
Read-only. Never print keys.
command -v codex && codex --version
ls -l "${CODEX_HOME:-$HOME/.codex}"/*.toml 2>/dev/null
grep -nE '^(model|model_provider|oss_provider|openai_base_url|model_context_window)\b|^\[model_providers\.' "${CODEX_HOME:-$HOME/.codex}/config.toml" 2>/dev/null
env | grep -E '^(OPENAI|CODEX|LITELLM)_' | sed -E 's/=.*/=<set>/'
Decision flow
- Endpoint serves
/v1/responses (vLLM, llama.cpp, Ollama, llama-swap, LiteLLM): define a provider with its base URL. -> references/custom-providers.md
- Chat-only endpoint: put LiteLLM in front; it bridges Responses to chat completions. Use the
litellm skill, then references/combos/litellm-responses-bridge.md.
- Ollama or LM Studio on the same machine, quick trial:
codex --oss. -> references/custom-providers.md
- Model names, context window, reasoning flags: ->
references/models-and-limits.md
- Tools, MCP, streaming, compaction misbehave: ->
references/compatibility.md
- Install or update: ->
references/install-and-update.md
- Error text: ->
references/troubleshooting.md
Rules
- Ask before changing the system. Installs, editing
~/.codex/config.toml, shell profile exports and exposing a gateway need approval and an undo path (copy the file first).
- Secrets never touch output or git. Use
env_key (the variable name) or [model_providers.<id>.auth] with a command. Avoid experimental_bearer_token, which writes the key into the file. Check presence with [ -n "${VAR:-}" ], never echo.
- Providers live in the user config. Project
.codex/config.toml ignores model_provider, model_providers, openai_base_url and profile. Switch per project with codex --profile <name>.
- Reserved IDs. Do not name a provider
openai, ollama or lmstudio. To repoint built-in OpenAI use openai_base_url.
- Responses only.
wire_api = "responses" is the only supported value. Older guides showing "chat" are obsolete.
- Declare limits. Set
model_context_window and model_auto_compact_token_limit for models Codex does not know.
- Test the endpoint first.
scripts/check-endpoint.sh before blaming Codex.
- Verify upstream. Keys, defaults and versions come from the Codex config reference and GitHub releases read on the writing date.
Workflows
Connect to a self-hosted endpoint
Fix a broken local setup
Reference index
| File |
Read when |
references/custom-providers.md |
Provider keys, auth, headers, profiles, --oss, per-engine setup |
references/models-and-limits.md |
Context window, compaction, reasoning, model catalog |
references/compatibility.md |
Responses features, tools, MCP, streaming, compaction, open issues |
references/install-and-update.md |
Install paths, updating, pinning, state directory |
references/troubleshooting.md |
Symptom to cause to fix |
references/combos/litellm-responses-bridge.md |
LiteLLM in front of chat-only engines |
Templates: templates/config.toml, templates/local.config.toml. Script: scripts/check-endpoint.sh (probes a Responses endpoint, prints status codes only).
Companion skills
Install any with npx skills add ScaleDockHQ/llm-skills --skill <name>.
litellm: bridges /v1/responses onto chat-only engines.
llm-gateway: whether to use a gateway and which one.
vllm, llama-cpp, ollama, llama-swap: the endpoints Codex talks to.
tool-calling-parsers: make tool calls parse on the engine side.
llm-clients: other clients (IDEs, chat UIs, SDKs).
1---2name: codex-cli3description: OpenAI Codex CLI, the terminal coding agent, pointed at self-hosted or gateway models through custom model providers over the Responses API. Use to install or update `codex`, write ~/.codex/config.toml model_providers (base_url, env_key, wire_api responses) for vLLM, llama.cpp, Ollama, LiteLLM or llama-swap, set profiles, context limits, fix 404 /v1/responses, MCP tools unsupported, compaction, auth. Not for Claude Code, OpenCode, Aider.4license: MIT5compatibility: Needs bash, curl and jq for the check script, and an endpoint that serves POST /v1/responses. Installs, updates, config edits and exposing a gateway need the user's explicit approval.6metadata:7 source: https://skillmd.com/skills/scaledockhq/codex-cli8 author: ScaleDockHQ9 version: "0.1.0"10---1112# Codex CLI1314Run `codex` against your own endpoint (vLLM, llama.cpp, Ollama, a LiteLLM or llama-swap gateway) with a custom model provider, a safe key setup, correct limits and a verified Responses endpoint.1516**Scope:** the Codex CLI and its `config.toml`. Gateways and engines belong to their own skills. Codex custom providers speak only the Responses API; there is no Chat Completions mode.1718Work through the steps in order. Load a reference only when a step names it.1920## Discover first2122Read-only. Never print keys.2324```bash25command -v codex && codex --version26ls -l "${CODEX_HOME:-$HOME/.codex}"/*.toml 2>/dev/null27grep -nE '^(model|model_provider|oss_provider|openai_base_url|model_context_window)\b|^\[model_providers\.' "${CODEX_HOME:-$HOME/.codex}/config.toml" 2>/dev/null28env | grep -E '^(OPENAI|CODEX|LITELLM)_' | sed -E 's/=.*/=<set>/'29```3031## Decision flow32331. **Endpoint serves `/v1/responses`** (vLLM, llama.cpp, Ollama, llama-swap, LiteLLM): define a provider with its base URL. -> `references/custom-providers.md`342. **Chat-only endpoint:** put LiteLLM in front; it bridges Responses to chat completions. Use the `litellm` skill, then `references/combos/litellm-responses-bridge.md`.353. **Ollama or LM Studio on the same machine, quick trial:** `codex --oss`. -> `references/custom-providers.md`364. **Model names, context window, reasoning flags:** -> `references/models-and-limits.md`375. **Tools, MCP, streaming, compaction misbehave:** -> `references/compatibility.md`386. **Install or update:** -> `references/install-and-update.md`397. **Error text:** -> `references/troubleshooting.md`4041## Rules4243- **Ask before changing the system.** Installs, editing `~/.codex/config.toml`, shell profile exports and exposing a gateway need approval and an undo path (copy the file first).44- **Secrets never touch output or git.** Use `env_key` (the variable name) or `[model_providers.<id>.auth]` with a command. Avoid `experimental_bearer_token`, which writes the key into the file. Check presence with `[ -n "${VAR:-}" ]`, never `echo`.45- **Providers live in the user config.** Project `.codex/config.toml` ignores `model_provider`, `model_providers`, `openai_base_url` and `profile`. Switch per project with `codex --profile <name>`.46- **Reserved IDs.** Do not name a provider `openai`, `ollama` or `lmstudio`. To repoint built-in OpenAI use `openai_base_url`.47- **Responses only.** `wire_api = "responses"` is the only supported value. Older guides showing `"chat"` are obsolete.48- **Declare limits.** Set `model_context_window` and `model_auto_compact_token_limit` for models Codex does not know.49- **Test the endpoint first.** `scripts/check-endpoint.sh` before blaming Codex.50- **Verify upstream.** Keys, defaults and versions come from the Codex config reference and GitHub releases read on the writing date.5152## Workflows5354### Connect to a self-hosted endpoint5556- [ ] Run discovery; back up `~/.codex/config.toml`.57- [ ] Put the key in a `0600` file and export it from the shell profile or launcher: `export LOCAL_LLM_API_KEY="$(cat ~/.config/llm/key)"`.58- [ ] `CODEX_BASE_URL=http://HOST:PORT/v1 CODEX_MODEL=<served-name> scripts/check-endpoint.sh` returns ok for models, plain, stream and tool probes.59- [ ] Add the provider and profile from `templates/` (`config.toml`, `local.config.toml`).60- [ ] `codex --profile local "list the files here"`, then a one-file edit.6162### Fix a broken local setup6364- [ ] 404, 400 or "unsupported": `references/troubleshooting.md`.65- [ ] Tool or MCP failures with llama.cpp, vLLM or Ollama: `references/compatibility.md` (known open issues, flags).6667## Reference index6869| File | Read when |70| ----------------------------------------------- | ------------------------------------------------------------------ |71| `references/custom-providers.md` | Provider keys, auth, headers, profiles, `--oss`, per-engine setup |72| `references/models-and-limits.md` | Context window, compaction, reasoning, model catalog |73| `references/compatibility.md` | Responses features, tools, MCP, streaming, compaction, open issues |74| `references/install-and-update.md` | Install paths, updating, pinning, state directory |75| `references/troubleshooting.md` | Symptom to cause to fix |76| `references/combos/litellm-responses-bridge.md` | LiteLLM in front of chat-only engines |7778Templates: `templates/config.toml`, `templates/local.config.toml`. Script: `scripts/check-endpoint.sh` (probes a Responses endpoint, prints status codes only).7980## Companion skills8182Install any with `npx skills add ScaleDockHQ/llm-skills --skill <name>`.8384- `litellm`: bridges `/v1/responses` onto chat-only engines.85- `llm-gateway`: whether to use a gateway and which one.86- `vllm`, `llama-cpp`, `ollama`, `llama-swap`: the endpoints Codex talks to.87- `tool-calling-parsers`: make tool calls parse on the engine side.88- `llm-clients`: other clients (IDEs, chat UIs, SDKs).