Codex (OpenAI)
Run new local Codex tasks through API-AI's streamed Responses API.
Run new local Codex tasks through API-AI's streamed Responses API.
Codex coding agent CLI and desktop app
What works
Supports streamed responses, function calls, local tools such as apply_patch, and usage accounting. This changes new local CLI, desktop, and IDE tasks; it does not change Codex cloud chats.
Client limitation
Restart Codex and create a new local task after changing the provider. Existing tasks keep the model and provider they started with.
Setup
Install or verify Codex
If codex --version already prints a version, continue. Otherwise install the current CLI.
npm install --global @openai/codex codex --versionMake a dedicated key available
Create a dedicated API-AI key and export it in the same terminal session that starts Codex.
export API_AI_KEY="mdf-your-key"Add the custom provider
Open ~/.codex/config.toml (desktop: Settings → Configuration → Open config.toml) and add the API-AI provider.
model_provider = "api-ai" [model_providers.api-ai] name = "API-AI" base_url = "https://api-ai.app/v1" env_key = "API_AI_KEY" wire_api = "responses"Restart and test a new local task
CLI users should run a read-only probe. Desktop users must fully quit, reopen, and start a new local task.
codex
Verify the connection
Confirm the request in your dashboard
The completed request should show the selected model, /v1/responses, token usage, and a settled charge.
Connection details
- Protocol
- responses
- Endpoint
- https://api-ai.app/v1
Key security
Use a dedicated scoped key. On macOS, a desktop app opened from the Dock may not inherit terminal environment variables; use Codex command-backed Keychain authentication instead of placing the secret in config.toml.