A single config.toml gets the local OpenAI Codex CLI talking to apimodels GPT-5.4 / GPT-5.5. This page shows the full config, reasoning-effort control, pricing, and a curl sanity check.
Usa wire_api = "responses" (no chat), base_url = "https://api.apimodels.app/v1", model = "gpt-5.4" (or "gpt-5.5"), set reasoning depth via model_reasoning_effort, and put your API key in the env var. Done.
Abre Consola en tu consola y crea una clave sk_….
Pega el fragmento de abajo en ~/.codex/config.toml (crea el archivo si no existe).
Exporta tu clave y luego simplemente ejecuta codex.
~/.codex/config.toml
# ~/.codex/config.toml — drop-in, paste as-is
model_provider = "apimodels"
model = "gpt-5.4" # or "gpt-5.5"
review_model = "gpt-5.5" # model used by /review
model_reasoning_effort = "medium" # low | medium | high | xhigh
disable_response_storage = true
[model_providers.apimodels]
name = "apimodels"
base_url = "https://api.apimodels.app/v1"
wire_api = "responses"
env_key = "APIMODELS_API_KEY"Shell
# put your apimodels key in the env var the config points at,
# then launch codex (add this line to ~/.zshrc to make it stick):
export APIMODELS_API_KEY="sk_…your_key…"
codex| Ajuste | Valor | Por qué |
|---|---|---|
| wire_api | responses | Codex's native mode — recommended. gpt-5-4 / 5-5 now work over both chat and responses, but Codex runs best on responses (native reasoning + multi-turn tool state). |
| base_url | https://api.apimodels.app/v1 | El prefijo de nuestro endpoint /v1 compartido. |
| model | gpt-5.4 / gpt-5.5 | Use Codex's dot names (gpt-5.4 / gpt-5.5); the dash forms gpt-5-4 / gpt-5-5 also work. |
| review_model | gpt-5.5 | Model used by the /review command. Optional — defaults to model above. |
| model_reasoning_effort | low / medium / high / xhigh | Codex turns this into the request-body reasoning.effort field — see below. |
| env_key | APIMODELS_API_KEY | Cualquier nombre: Codex simplemente lee la variable de entorno que le indiques. |
| model_provider | apimodels | Debe coincidir con la clave de la tabla [model_providers.<name>] de abajo. |
Reasoning depth is the reasoning.effort field in the request body (Codex sets it via model_reasoning_effort) — no longer a model-name suffix. All levels share the same per-token price; higher effort just emits more reasoning_tokens (billed as part of output_tokens). When calling the API directly, pass "reasoning": { "effort": "high" }.
| reasoning.effort | Usar para |
|---|---|
| low | Fast / single-step / simple completions (default) |
| medium | Refactorizaciones de varios pasos, compromisos de diseño |
| high | Depuración difícil, análisis entre archivos |
| xhigh | Los problemas más difíciles: dale espacio para pensar |
Output tokens include reasoning tokens. Each call is billed against your apimodels balance. Pricing for other models is in /docs/llm.
Antes de instalar Codex, confirma que el endpoint y tu clave funcionan con un solo curl:
curl -s https://api.apimodels.app/v1/responses \
-H "Authorization: Bearer $APIMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "Reply with exactly: ok",
"reasoning": { "effort": "low" },
"max_output_tokens": 16
}'Respuesta esperada (truncada):
{
"id": "resp_...",
"object": "response",
"model": "gpt-5.4",
"status": "completed",
"output": [{
"type": "message",
"role": "assistant",
"content": [{ "type": "output_text", "text": "ok" }]
}],
"usage": {
"input_tokens": 22,
"output_tokens": 5,
"total_tokens": 27
}
}HTTP 200 with output[].content[0].text === "ok" means you're good to go.
gpt-5-4 / gpt-5-5 now work either way. For Codex use wire_api = "responses" — its native mode, which handles reasoning and multi-turn tool calls most cleanly. If your client only speaks OpenAI chat format, wire_api = "chat" against /v1/chat/completions reaches these models too. For ordinary chat models (deepseek-v4-flash, Claude, Gemini, …) just use chat.
| Síntoma | Causa / solución |
|---|---|
| HTTP 401 Invalid or missing API key | La variable de entorno no se exportó o la clave fue deshabilitada. Vuelve a exportar APIMODELS_API_KEY=… o genera una nueva clave en la consola. |
| HTTP 400 Unknown model | Model name typo. Use gpt-5.4 / gpt-5.5 (dots, Codex default); gpt-5-4 / gpt-5-5 also work. |
| 404 / endpoint no encontrado | Wrong base_url — it must be https://api.apimodels.app/v1 (include /api/v1, no trailing slash). Codex appends /responses itself. |
| Respuesta vacía o solo razonamiento sin texto visible | max_output_tokens demasiado bajo: los tokens de razonamiento se comieron el presupuesto. Deja varios cientos de tokens para high/xhigh. |
| Factura más alta de lo esperado | output_tokens includes reasoning_tokens — at effort high / xhigh these can be many times the visible output. Pick the lowest effort that meets your quality bar. |