ai2saveai2save

Codex CLI with a custom API endpoint: config.toml setup

Use OpenAI's Codex CLI with ai2save as a third-party gateway. The base URL is https://ai2save.com/v1; use an ai2save API key, not a ChatGPT login. In the console, choose a group that supports the Responses API and copy an enabled model ID.

Maintained by ai2save. Updated 2026-11-18. Tested with codex-cli 0.155.1 against a local Responses endpoint; this checks the client configuration, not live model availability.

1. Install and choose a provider

Install the tested version with npm install -g @openai/[email protected] and check codex --version. In ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml), merge these settings with your existing configuration. Put the top-level keys before any [table]. Replace YOUR_MODEL_ID with your group's exact model ID.

model = "YOUR_MODEL_ID"
model_provider = "ai2save"

[model_providers.ai2save]
name = "ai2save"
base_url = "https://ai2save.com/v1"
env_key = "AI2SAVE_API_KEY"
wire_api = "responses"

Check the GPT models, public group prices and worked cost example before the first billable request.

2. Make one request

Set AI2SAVE_API_KEY in this terminal using your secret manager, or enter it without saving it in shell history. For example, in Bash:

read -rs -p 'ai2save API key: ' AI2SAVE_API_KEY; echo
export AI2SAVE_API_KEY

In PowerShell 7.1 or later: $env:AI2SAVE_API_KEY = Read-Host 'ai2save API key' -MaskInput. From a trusted Git working directory run:

codex exec --ephemeral --sandbox read-only "Reply with only: OK"

A successful run prints an assistant reply (for this prompt, normally OK) and exits with status 0. A startup banner alone is not a response. The CLI appends /responses; do not append it to the base URL yourself.

3. Identify the failing step

  • 401 / invalid API key: verify AI2SAVE_API_KEY is set in the same terminal and belongs to this gateway. Do not paste it into a ticket, screenshot or config file.
  • Model not found / not allowed: check the model ID, its group and Responses support. Changing the key string will not enable an unavailable model.
  • Endpoint not found: check the host and the single /v1 prefix. An endpoint error is different from an error naming the model.

Upstream sources: OpenAI Codex CLI and Codex configuration reference.