Skip to content

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:

bash
npm install -g @openai/codex

Or run directly with npx (no installation required):

bash
npx @openai/codex

Verify installation:

bash
codex --version

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

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:

bash
export AGENTSFLARE_API_KEY="Your Agentsflare API Key"
codex

On Windows PowerShell:

powershell
$env:AGENTSFLARE_API_KEY = "Your Agentsflare API Key"
codex

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

ItemValue
Provider base URL in config.tomlhttps://api.agentsflare.com/v1
Actual request sent by CodexPOST 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:

  1. ~/.codex/config.yaml is not Codex's user configuration file. The file is ~/.codex/config.toml.
  2. Top-level api_key and base_url do not define a selected custom provider. The provider must be declared under [model_providers.<id>], and model_provider must point to that ID.
  3. OPENAI_BASE_URL and OPENAI_API_KEY configure the built-in OpenAI path; they do not replace the explicit custom-provider selection shown above.
  4. A project-local .codex/config.toml cannot override machine-local provider settings. Put model_provider and [model_providers.agentsflare] in the user-level ~/.codex/config.toml.

Verify the Active Route

Run the diagnostic first:

bash
codex doctor

The report should show all of the following:

  • config.toml loaded 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:

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

bash
codex

Execute a single instruction directly:

bash
codex "Refactor utils.js into TypeScript"

Launch with a specific model:

bash
codex --model gpt-5.3-codex

View help:

bash
codex --help

This documentation is licensed under CC BY-SA 4.0.