Agentsflare Codex Configuration Guide
Codex is OpenAI's official CLI coding tool that supports natural language instructions for code writing, debugging, and refactoring.
Installing Codex
Install globally via npm:
npm install -g @openai/codexOr run directly with npx (no installation required):
npx @openai/codexVerify installation:
codex --versionConfiguring Codex with Agentsflare
Codex uses a TOML configuration file, not YAML. See the official configuration basics and configuration reference. To ensure requests use Agentsflare instead of Codex's built-in OpenAI provider, define an explicit custom provider and select it as the default provider.
1. Create the user-level configuration file
Create or modify the following file:
- macOS / Linux:
~/.codex/config.toml - Windows:
%USERPROFILE%\\.codex\\config.toml
Put the following content in config.toml:
model = "gpt-5.3-codex"
model_provider = "agentsflare"
[model_providers.agentsflare]
name = "Agentsflare"
base_url = "https://api.agentsflare.com/v1"
env_key = "AGENTSFLARE_API_KEY"
requires_openai_auth = false
wire_api = "responses"2. Provide the Agentsflare API key
Set the environment variable before launching Codex:
export AGENTSFLARE_API_KEY="Your Agentsflare API Key"
codexOn Windows PowerShell:
$env:AGENTSFLARE_API_KEY = "Your Agentsflare API Key"
codexenv_key tells Codex which environment variable supplies the key. Keep the key out of config.toml and do not use OPENAI_API_KEY as the only configuration: that variable is associated with Codex's built-in OpenAI provider and does not select the Agentsflare provider.
Endpoint Rules
This configuration uses the Responses API, which is the protocol Codex expects for this provider:
| Item | Value |
|---|---|
Provider base URL in config.toml | https://api.agentsflare.com/v1 |
| Actual request sent by Codex | POST https://api.agentsflare.com/v1/responses |
Required wire_api | "responses" |
Do not put /responses or /chat/completions in base_url. Codex appends the route selected by wire_api; including a full endpoint path can produce an invalid duplicated path. Do not configure Codex with wire_api = "chat" for this integration.
Why the Previous Configuration Did Not Work
The previous example could leave Codex on the OpenAI address for several reasons:
~/.codex/config.yamlis not Codex's user configuration file. The file is~/.codex/config.toml.- Top-level
api_keyandbase_urldo not define a selected custom provider. The provider must be declared under[model_providers.<id>], andmodel_providermust point to that ID. OPENAI_BASE_URLandOPENAI_API_KEYconfigure the built-in OpenAI path; they do not replace the explicit custom-provider selection shown above.- A project-local
.codex/config.tomlcannot override machine-local provider settings. Putmodel_providerand[model_providers.agentsflare]in the user-level~/.codex/config.toml.
Verify the Active Route
Run the diagnostic first:
codex doctorThe report should show all of the following:
config.tomlloaded from~/.codex/config.toml;- default model provider
agentsflare; - OpenAI authentication not required;
- custom API base URL
https://api.agentsflare.com/v1; - a reachable provider route.
Then send one real request:
codex exec --skip-git-repo-check "Reply with exactly: AGENTSFLARE_OK"If the request still reaches an OpenAI address, check that model_provider = "agentsflare" is at the top level of the user config, that the section is named exactly [model_providers.agentsflare], and that the command is not being run with --ignore-user-config or a different CODEX_HOME.
Common Commands
Start an interactive session:
codexExecute a single instruction directly:
codex "Refactor utils.js into TypeScript"Launch with a specific model:
codex --model gpt-5.3-codexView help:
codex --help