Suanlimao
← Back to all tutorials

Connect your tools

Codex CLI

Add a custom provider to Codex's config file.

About 8 minFor:Developers using the Codex CLI

Before you start

  • Codex CLI is installed
  • An API key
  • A model with the Responses tag on the plaza — Codex uses the /v1/responses API

Step 1 · STEP 0x01

Put the key in an environment variable

Codex does not store the key in its config; it reads it from an environment variable you name. We use RELAY_API_KEY here — the name is up to you.

bash
export RELAY_API_KEY=<YOUR_API_KEY>
terminal
$ export RELAY_API_KEY=<YOUR_API_KEY>
The full key is shown only once, at creation. Missed it? Revoke it and create a new one.

Create a key →

Step 2 · STEP 0x02

Add a provider to the config file

Edit .codex/config.toml in your home folder (~/.codex/config.toml; on Windows the .codex folder in your user directory). Pick your own provider id — reserved names such as openai and ollama are not allowed.

toml
model = "<MODEL_NAME>"
model_provider = "relay"

[model_providers.relay]
name = "Suanlimao"
base_url = "https://api.suanlimao.shop/v1"
env_key = "RELAY_API_KEY"
wire_api = "responses"
terminal
$ cat ~/.codex/config.tomlmodel = "<MODEL_NAME>"model_provider = "relay"…
  • model: a name copied from the plaza that carries the Responses tag.
  • base_url: the base address, with /v1.
  • env_key: the variable name from the previous step.
  • wire_api = "responses": tells Codex to use the Responses API.
Define providers in the user-level ~/.codex/config.toml; project-level .codex/config.toml files ignore model_provider and model_providers.

Open the model plaza →

Step 3 · STEP 0x03

Run it and try a prompt

terminal
$ codex> 你好(正常回答即成功)
Codex only sees the variable set in the same terminal; in a new window set it again or add it to your shell profile.

✓ How to tell it worked

  • Codex answers normally and the Usage page shows the request.

FAQ

It says the environment variable is missing.

The name in env_key must match what you exported, and it must be set in the terminal that runs codex.

404 or “responses not supported”?

The model does not have the Responses API. Pick one that carries the tag or ask support when it will.

Can I use the chat API instead?

Codex's own examples all use wire_api = "responses" and the docs do not describe other values, so we only document this one.

Related tutorials

Still stuck?

Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).