Configure a named Codex provider with its Responses endpoint and environment credential. Verify streaming, tools, usage and rollback before using a gateway for real work.
Explanation reviewed:
Check the protocol before changing anything
Ask the gateway for its Responses API endpoint, exact model identifier and authentication method. OpenAI-compatible Chat Completions alone is not sufficient: the current Codex configuration reference supports responses as the wire_api value.
Record the installed Codex version and the gateway documentation you used. A provider logo or “compatible” marketing label does not prove tool-call or streaming compatibility. This is a setup procedure, not a paid API compatibility result from AI Price Spy.
Use a separate named provider
Back up the existing user configuration and authentication settings. Add a custom provider in your user Codex configuration; choose a distinct provider name rather than overwriting a built-in provider.
Replace the placeholder endpoint and model below with documented values. Set the named credential environment variable locally using your approved secret mechanism. The sample contains no key; do not add credentials to a committed project configuration.
Verify one small task before normal work
Start a session with the intended provider and model, check the displayed selection, and use a disposable small project. Check one text response, one permitted tool action and the complete streamed result. Review the provider usage record and billed amount for that same request.
A successful model-list request does not validate the task path. Keep the acceptance result, version, endpoint and date; only then describe that specific combination as tested. No billable gateway request has been made for this guide.
Diagnose a failure and restore the original configuration
For authentication errors, check that the expected environment variable is available to this process and that the key belongs to this gateway. For unknown-model or route errors, compare the exact identifier and base URL with the gateway docs. For stalled streams or missing tools, stop and check Responses support.
Do not repeatedly retry a charged request without inspecting the failure. Restore the backed-up configuration and restart the session if the new route cannot satisfy the task. Keep subscription allowances and gateway API charges separate.
model = "REPLACE_WITH_DOCUMENTED_MODEL_ID"
model_provider = "my_gateway"
[model_providers.my_gateway]
name = "My gateway"
base_url = "https://gateway.example/v1"
env_key = "MY_GATEWAY_API_KEY"
wire_api = "responses"