Skip to content

Codex

Codex is OpenAI’s terminal coding agent. It supports custom model providers, so you can point it at ru-llm’s OpenAI-compatible surface.

Configure

Add a provider block to ~/.codex/config.toml pointing base_url at the gateway’s /v1 path:

~/.codex/config.toml
model = "gpt-5.5"
model_provider = "ru-llm"
[model_providers.ru-llm]
name = "ru-llm"
base_url = "https://api.ru-llm.relay2.xyz/v1"
wire_api = "chat"
env_key = "RU_LLM_API_KEY"

Then export your key under the name you set in env_key:

Terminal window
export RU_LLM_API_KEY="sk-ru-YOUR_KEY"
codex

Select a model

Set model in config.toml (or pass --model on the CLI) to any chat model ID from the catalog — for example gpt-5.5, gpt-5.4, claude-opus-4-8, or gemini-3.1-pro-preview. Thanks to cross-dialect routing, Codex can drive Claude and Gemini models through the same OpenAI-style provider:

model = "claude-opus-4-8"

Verify

Check the OpenAI surface responds before launching Codex:

Terminal window
curl https://api.ru-llm.relay2.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-ru-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [{"role": "user", "content": "Reply with the single word: ok"}]
}'

A 200 with a choices[0].message.content of ok confirms the provider is reachable.

Troubleshooting

SymptomCauseFix
404 / “unknown endpoint”wire_api defaulted to responsesSet wire_api = "chat" in the provider block.
401 UnauthorizedKey env var not setExport the variable named in env_key (e.g. RU_LLM_API_KEY).
402 Payment RequiredZero balanceTop up in the console → Billing.
400 unknown modelModel ID not in catalogSet model to a listed ID (GET /v1/models).