Skip to content

Codex CLI and Codex Desktop

View as Markdown

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.

  1. Keep the API key in an environment variable. Add this line to ~/.zshrc or ~/.bashrc so new terminals have it too:

    Terminal window
    export VIKEY_API_KEY=YOUR_API_KEY
  2. 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"
  3. Run codex. Change the model for one session with codex -m openai/gpt-6.1-sol.

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 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:

Terminal window
launchctl setenv VIKEY_API_KEY YOUR_API_KEY

launchctl 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.

Since Codex 0.134, profiles are separate files. An example budget profile in ~/.codex/budget.config.toml:

~/.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.

Terminal window
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".

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