DocsCoding agents
Codex CLI
Run OpenAI's Codex CLI on your Osarai instance through a custom model provider that speaks the Responses API.
Codex CLI is OpenAI's coding agent for the terminal. It talks to custom providers over the Responses API only, which Osarai serves at https://osarai.xyz/v1/responses.

Install
Terminal
npm install -g @openai/codexTerminal
brew install --cask codexConfigure
Add a provider to Codex's configuration file and make it the default:
~/.codex/config.toml
model = "gpt-oss-20b"
model_provider = "osarai"
model_context_window = 131072
model_auto_compact_token_limit = 110000
model_reasoning_effort = "medium"
[model_providers.osarai]
name = "Osarai"
base_url = "https://osarai.xyz/v1"
env_key = "OSARAI_API_KEY"
wire_api = "responses"%USERPROFILE%.codex\config.toml
model = "gpt-oss-20b"
model_provider = "osarai"
model_context_window = 131072
model_auto_compact_token_limit = 110000
model_reasoning_effort = "medium"
[model_providers.osarai]
name = "Osarai"
base_url = "https://osarai.xyz/v1"
env_key = "OSARAI_API_KEY"
wire_api = "responses"| Key | Why |
|---|---|
model | Your instance's model id |
model_provider | Selects the [model_providers.osarai] block below |
model_context_window | The real context window: Codex has no metadata for open models |
model_auto_compact_token_limit | Compact the conversation before it reaches the window |
model_reasoning_effort | low, medium or high, sent as reasoning.effort |
base_url | Includes /v1 |
env_key | The environment variable that holds your key; Codex sends it as Authorization: Bearer |
wire_api | Must be responses: newer Codex releases no longer accept chat |
Run
Terminal
export OSARAI_API_KEY="qck_your_key_here"
cd your-project
codexThe header shows model: gpt-oss-20b and provider: osarai. To run one prompt and exit:
Terminal
codex exec "Explain what src/math.ts does" < /dev/nullcodex exec reads extra input from standard input when it is not a terminal; < /dev/null stops it waiting in scripts and CI.
Switching models
A profile is a second file next to config.toml, named <profile>.config.toml. Its keys override the main file, so the provider carries over:
~/.codex/qwen.config.toml
model = "qwen3.8-27b"
model_context_window = 131072Terminal
codex --profile qwenTroubleshooting
| Symptom | Fix |
|---|---|
Model metadata for … not found | Expected for open models; model_context_window tells Codex the window |
401 Unauthorized | OSARAI_API_KEY is not set in the shell that started Codex, or env_key names another variable |
wire_api = "chat" is no longer supported | Set wire_api = "responses" |
404 on /v1/v1/responses | base_url ends with /v1 once, not twice |
503 … not ready yet | The instance is still starting; wait for Ready on the instance page |
codex exec never exits | Add < /dev/null so it does not wait for standard input |
--profile … cannot be used while config.toml contains legacy … [profiles.…] | Move the [profiles.name] table into ~/.codex/name.config.toml |