Troubleshooting · Codex CLI

Codex config.toml Errors — model_providers Setup That Works

Codex fails to load a malformed ~/.codex/config.toml: unknown provider names, wrong wire_api, missing sections. The exact structure a custom provider needs.

What you see

codex config.toml error

Why it happens

  • model_provider names a provider that has no matching [model_providers.<name>] section — the reference and the section must use the same identifier.
  • TOML syntax errors: an unclosed string, a section header typo, or values pasted from JSON with commas and braces.
  • wire_api does not match what the endpoint serves, so requests are shaped for the wrong protocol.
  • The file edited is not the file Codex reads — a profile file passed with --profile has a specific expected location and name.

How to fix it

  • Keep the provider identifier identical in both places: model_provider = "apitoken" must be matched by [model_providers.apitoken].
  • Use wire_api = "responses" for a Responses-API endpoint — this gateway's OpenAI-compatible surface serves Responses and Chat Completions.
  • Validate the file is real TOML: strings quoted, one key = value per line, section headers in brackets.
  • Run codex --profile <name> and watch which file it reports loading; fix that file, not a lookalike.

Minimal correct profile

model = "gpt-5.6-sol"
model_provider = "apitoken"

[model_providers.apitoken]
name = "apiToken.sale"
base_url = "https://openai.api.apitoken.sale/v1"
wire_api = "responses"
env_key = "APITOKEN_API_KEY"

Related searches

  • unknown model provider
  • codex model_providers not working

FAQ

Why does Codex say my model provider is unknown?+
The model_provider value must exactly match a [model_providers.<name>] section in the same file. A typo on either side breaks the lookup.
Should wire_api be responses or chat?+
Whatever the endpoint serves. This gateway's OpenAI-compatible surface accepts the Responses API — wire_api = "responses" — and Chat Completions as well.
Does the base_url need /v1?+
For Codex profiles against this gateway, yes: the documented value is https://openai.api.apitoken.sale/v1, exactly as shipped in the docs.

Skip the broken setup

apiToken.sale serves the standard Anthropic API — same models, same SDKs, one prepaid balance. Point your tool's base URL at it, and the config on this page works as written.