Use ApexApi with Codex CLI

Codex CLI is OpenAI's terminal coding agent. Add ApexApi as a custom model provider and it can run any model from our catalog, billed to one balance.

1. Get your API key

Create a key in your dashboard. It starts with ak-.

2. Add ApexApi as a model provider

Edit ~/.codex/config.toml (create it if it doesn't exist) and add:

model = "openai/gpt-5.6-sol"
model_provider = "apexapi"

[model_providers.apexapi]
name = "ApexApi"
base_url = "https://api.apexapi.dev/v1"
env_key = "APEXAPI_API_KEY"
wire_api = "chat"

wire_api = "chat" tells Codex to speak the Chat Completions protocol, which ApexApi serves at /v1/chat/completions.

3. Export your key

export APEXAPI_API_KEY=ak-your-key-here

If you were previously signed in with a ChatGPT account, run codex logout first; a stored session overrides the config file.

4. Pick your model

The model value is any ApexApi catalog ID, for example:

openai/gpt-5.6-sol
anthropic/claude-sonnet-4.6
deepseek/deepseek-v4-pro

The ID must match the catalog exactly, in provider/model format. Browse all IDs on the models page.

5. Run it

codex "explain what this repo does"

Troubleshooting

  • 401 Unauthorized: the key wasn't pasted correctly or has been revoked.
  • Model not found: the model ID doesn't match a catalog ID. Copy it verbatim from the models page.
  • Connection fails: make sure the base URL is exactly https://api.apexapi.dev/v1 (no trailing slash after v1) and your balance is positive.
  • Codex ignores the config: a leftover ChatGPT login takes precedence. Run codex logout and start Codex again.
  • Anything else: check the error codes reference; streaming and tool calling are fully supported on /v1/chat/completions.