aiohub provider and let Codex CLI read the API key from an environment variable.
Prerequisites
- Codex CLI installed
- An AIOHub
sk-API key - A group assigned to the API key that can access the Codex / GPT model you want to use
- A positive account balance
Setup
1. Set the API key
~/.zshrc, ~/.bashrc, or your shell profile if you want it to persist.
2. Configure the provider
Edit~/.codex/config.toml. Use a separate aiohub provider instead of overriding Codex CLI’s built-in openai provider.
Configuration file locations:
| System | Path |
|---|---|
| macOS / Linux | ~/.codex/config.toml |
| Windows | %USERPROFILE%\.codex\config.toml |
Set
base_url to the /v1 root, not /v1/responses. supports_websockets = false keeps Codex using Responses over HTTP/SSE, which matches the current AIOHub gateway setup.Optional: sync Codex App sessions
If you want Codex App sessions to sync between your phone and computer, let the AIOHub provider depend on your official OpenAI account login. The key setting isrequires_openai_auth = true.
Sign in to the same ChatGPT account in Codex App on both your phone and computer, then use this configuration in ~/.codex/config.toml:
This configuration is for Codex App workflows that need OpenAI account session sync. If you only use AIOHub in Codex CLI, keep using the
env_key setup above with requires_openai_auth = false.Verify
Check that the environment variable exists without printing the API key:| Command | Use |
|---|---|
codex | Start interactive mode |
codex "explain this project" | Start interactive mode with an initial prompt |
codex exec "count files in this directory" | Run one non-interactive task |
Configuration notes
| Setting | Meaning |
|---|---|
model_provider | Selects the custom provider |
base_url | AIOHub OpenAI-compatible root, including /v1 |
env_key | Environment variable where Codex CLI reads the AIOHub API key |
experimental_bearer_token | Writes the AIOHub API key directly in the config file; use only when you need Codex App session sync |
wire_api | Codex CLI uses responses |
requires_openai_auth | Use false for independent CLI API-key auth; use true when Codex App should sync sessions through the same ChatGPT account |
supports_websockets | false uses HTTP/SSE Responses transport |
model | Change this to a model available to the group assigned to your API key |
model_reasoning_effort | Reasoning effort: low, medium, high, or xhigh |
disable_response_storage | Requests upstream response-storage opt-out when supported |
Troubleshooting
Codex CLI cannot connect
Codex CLI cannot connect
Confirm
base_url is https://api.aiohub.org/v1, AIOHUB_API_KEY is set, and your network can reach api.aiohub.org.Model not available
Model not available
Check that the group assigned to your API key can access the requested model in the console.
Requests go to the official OpenAI account
Requests go to the official OpenAI account
Confirm
model_provider = "aiohub" and keep AIOHub out of the built-in openai provider. With requires_openai_auth = false, Codex CLI uses the API key from the variable named by env_key.WebSocket or Realtime errors
WebSocket or Realtime errors
Keep
supports_websockets = false. Codex CLI will use Responses HTTP/SSE transport and will not require a Responses WebSocket gateway.Responses Compact errors
Responses Compact errors
/v1/responses/compact is only for models or routes that support compact. A normal Codex CLI session should keep wire_api = "responses" and must not set base_url to /v1/responses/compact.