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.
Use wire_api = "responses" (não 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.
Abra Console no seu console e crie uma chave sk_….
Cole o trecho abaixo em ~/.codex/config.toml (crie o arquivo se necessário).
Exporte sua chave e depois é só executar 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| Configuração | 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 | O prefixo do nosso endpoint /v1 compartilhado. |
| 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 | Qualquer nome — o Codex apenas lê a variável de ambiente que você indicar. |
| model_provider | apimodels | Deve corresponder à chave da tabela [model_providers.<name>] abaixo. |
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 | Refatorações de várias etapas, decisões de design |
| high | Depuração difícil, análise entre arquivos |
| xhigh | Os problemas mais difíceis — dê a ele espaço 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 o Codex, confirme que o endpoint e sua chave funcionam com um único 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
}'Resposta 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.
| Sintoma | Causa / correção |
|---|---|
| HTTP 401 Invalid or missing API key | A variável de ambiente não foi exportada ou a chave foi desativada. Reexporte APIMODELS_API_KEY=… ou gere uma nova chave no console. |
| 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 não encontrado | Wrong base_url — it must be https://api.apimodels.app/v1 (include /api/v1, no trailing slash). Codex appends /responses itself. |
| Resposta vazia ou apenas raciocínio sem texto visível | max_output_tokens muito baixo — os tokens de raciocínio consumiram o orçamento. Deixe várias centenas de tokens para high/xhigh. |
| Cobrança maior do que o 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. |