Codex CLI and Codex Desktop
Codex uses the OpenAI Responses format (/v1/responses). Vikey supports it for every text model, including Claude and DeepSeek.
Tested with Codex CLI 0.167 on 13 November 2026.
Recommended config
Section titled “Recommended config”-
Keep the API key in an environment variable. Add this line to
~/.zshrcor~/.bashrcso new terminals have it too:Terminal window export VIKEY_API_KEY=YOUR_API_KEY -
Add the Vikey provider to
~/.codex/config.toml:~/.codex/config.toml model = "vikey/agent-gpt"model_provider = "vikey"[model_providers.vikey]name = "Vikey"base_url = "https://api.vikey.ai/v1"env_key = "VIKEY_API_KEY"wire_api = "responses" -
Run
codex. Change the model for one session withcodex -m openai/gpt-6.1-sol.
Why each line is there
Section titled “Why each line is there”| Line | Purpose |
|---|---|
model |
Default model. A fixed model such as openai/gpt-6.1-sol or Vikey Auto such as vikey/agent-gpt. |
model_provider |
Selects the vikey provider defined below it. openai, ollama and lmstudio are taken by Codex, so do not use them as the provider id. |
base_url |
With /v1. Codex adds /responses itself. |
env_key |
Name of the environment variable that holds the key. The key is not written in the file. |
wire_api = "responses" |
Must be "responses". Current Codex rejects "chat" with wire_api = "chat" is no longer supported. |
Codex Desktop (macOS)
Section titled “Codex Desktop (macOS)”Codex Desktop uses the same ~/.codex/config.toml. The difference: an app opened from the Dock does not see variables exported in a terminal. Register the key at the OS level, then quit Codex Desktop completely and open it again:
launchctl setenv VIKEY_API_KEY YOUR_API_KEYlaunchctl setenv is cleared when the Mac restarts. Run it again after a restart, or open Codex Desktop from a terminal that has VIKEY_API_KEY.
Several setups (profiles)
Section titled “Several setups (profiles)”Since Codex 0.134, profiles are separate files. An example budget profile in ~/.codex/budget.config.toml:
model = "vikey/agent-mocin"model_provider = "vikey"Run it with codex --profile budget. The vikey provider still comes from ~/.codex/config.toml.
Test the connection
Section titled “Test the connection”curl -sS https://api.vikey.ai/v1/responses \ -H "Authorization: Bearer $VIKEY_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "openai/gpt-6-luna", "input": "ping"}'A response with "output" means the key and base URL are right. Then try codex exec "reply with the word ok".
Common problems
Section titled “Common problems”| What you see | Cause | Fix |
|---|---|---|
401 or Missing environment variable VIKEY_API_KEY |
The variable is not exported in this terminal, or Codex Desktop cannot see it | export VIKEY_API_KEY=..., or launchctl setenv for Codex Desktop |
404 on /v1/v1/responses |
/v1 written twice |
base_url is just https://api.vikey.ai/v1 |
wire_api = "chat" is no longer supported |
An old config | Change it to wire_api = "responses" |
Model '...' not found |
A typo in the model id | Get the id from GET /v1/models or the pricing page |