Codex
Codex CLI talks to kenari through a custom provider in ~/.codex/config.toml. Recent Codex versions only use the Responses API format, so the provider must point at kenari’s /v1/responses endpoint. See Responses for the endpoint itself.
Configure the provider
Section titled “Configure the provider”Create or edit ~/.codex/config.toml:
model = "step-3-7-flash:free"model_provider = "kenari"
[model_providers.kenari]name = "kenari"base_url = "https://kenari.id/v1"wire_api = "responses"env_key = "KENARI_API_KEY"requires_openai_auth = false| Setting | Value |
|---|---|
model | A model id from Models and pricing. step-3-7-flash:free runs with zero balance. |
base_url | https://kenari.id/v1. Unlike Claude Code, Codex needs the /v1. |
wire_api | responses. Codex no longer accepts chat. |
env_key | The name of the environment variable that holds your key. |
Then export your key in the shell that runs Codex:
export KENARI_API_KEY=kn-...Create the key under API Keys in the dashboard. See Authentication and API keys.
Store the key in auth.json instead
Section titled “Store the key in auth.json instead”If you would rather keep the key in ~/.codex/auth.json, set requires_openai_auth = true and remove the env_key line. Then store the kenari key in that file by running this command, which reads the key from the environment variable and writes it to auth.json:
printenv KENARI_API_KEY | codex login --with-api-keyThe file should then hold the kenari key and nothing else:
{ "OPENAI_API_KEY": "kn-..." }The field is named OPENAI_API_KEY because Codex uses that name for any API key. The value is your kenari key.
Verify the connection
Section titled “Verify the connection”Start Codex and send a short prompt:
codexA reply means the connection works.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
401 with invalid key or missing authorization | KENARI_API_KEY is not set in this shell, or the key does not start with kn-. | Export the key again, then restart Codex. |
400 with model_not_found | The model id is misspelled or not in the catalog. | Copy the id from Models and pricing. |
402 with insufficient_balance | The model is paid and your balance is empty. | Use a :free model, or top up. See How billing works. |
405 | base_url has a doubled /v1 or is missing it. | Set base_url to exactly https://kenari.id/v1. |