Thelsy
Codex CLI

Point Codex CLI at a custom provider

Codex CLI can run against any provider that speaks the Responses API, not just the official one. The configuration is four lines — but there is one flag that turns a working setup into a confusing failure if you leave it out, and the error message does not point at the flag.

1. The whole configuration

Put this in ~/.codex/config.toml. The name after model_provider is arbitrary; it just has to match the table header below it.

~/.codex/config.toml
model = "your-model-id"
model_provider = "custom"
disable_response_storage = true

[model_providers.custom]
base_url = "https://your-endpoint.example.com/v1"
wire_api = "responses"

Three of those lines are ordinary. base_url is the /v1 root of the provider, and wire_api = "responses" tells the client to use the Responses protocol instead of chat completions.

2. Why disable_response_storage = true is not optional

By default the Responses API expects the server to keep conversation state, so a follow-up request can refer to a previous response by id. A third-party endpoint does not offer that storage, and Codex keeps requesting it anyway.

The failure looks like this:

error
stream closed before response.completed
Nothing in that message mentions storage. This is why people spend an afternoon checking their API key and network before finding a one-line flag.

3. Check the account before you blame the config

If your provider is also OpenAI-compatible, a plain chat request tells you whether the key, the model id and the balance are fine — in about ten seconds, with no agent in the loop:

terminal
curl https://your-endpoint.example.com/v1/chat/completions \
  -H "Authorization: Bearer $YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-model-id","messages":[{"role":"user","content":"ping"}]}'

If that returns a normal completion, the account side is healthy and any remaining problem is in how the client talks to the provider. If it fails, fix that first — Codex will not give you a clearer error than this will.

4. What to watch once it runs

Where Thelsy fits

We serve an OpenAI-compatible endpoint that Codex CLI drives with wire_api = "responses", plus an Anthropic-compatible endpoint on the same host for Claude Code. Card subscription, per-request token usage in the console, invoices handled by our merchant of record. When a plan's included tokens run out, calls stop — there is no automatic overage charge.