Tool Integration

Codex API gateway configuration tutorial: Custom Provider and Responses API

Configure Codex custom Provider, Base URL, environment variables and Responses API, call it with the minimum file task verification tool, and troubleshoot /v1/v1, environment variables and protocol compatibility issues.

Updated on 2026-07-18Checked 2026-07-18Estimated reading time: 8 minutesApplies to Codex Responses API
Configuration fields were checked against public documentation. Models, prices, and capabilities can change; verify current values in the console and live API responses.
Special topic: AI development tool custom API access center

Codex supports defining model providers through configuration files. When connecting to a third-party compatible API, the key point is base_url, authentication environment variables, model ID, and wire_api. The current official configuration reference will be wire_api defined as responses, so the compliant service must actually support the Responses API; simply supporting Chat Completions is not enough to cover the Codex's agent tasks.

Quick conclusion

Codex custom providers require a real and available Responses API. put wire_api set to responses, Key put in env_key Point to the environment variable and create the file and display with git diff Minimum task acceptance; ordinary chat success cannot replace tool events and session link verification.

Check before you start

First confirm that the target model and API support the Responses API. Don't infer that just because the normal chat API is available, file operations, tool calls, and continuous agent tasks are also available.

Prepare independent environment variables:

export AIFAST_API_KEY="yours_API_Key"

Configuration steps

at user level ~/.codex/config.toml Add custom providers. project level .codex/config.toml cannot overwrite model_providermodel_providers and Provider certification. Example structure:

model = "YOUR_MODEL_ID"
model_provider = "aifast"

[model_providers.aifast]
name = "AIQuick stop"
base_url = "https://www.aifast.club/v1"
env_key = "AIFAST_API_KEY"
wire_api = "responses"

Note:

  • YOUR_MODEL_ID Must be replaced with the model ID that the console actually opens.
  • If the service only supports Chat Completions, don't assume that changing one field will fully support Codex.
  • The API Key is placed in the environment variable and is not written. config.toml
  • Custom Provider ID Do not use reserved openaiollama or lmstudio
  • The regular Responses address corresponding to the above Base URL is https://www.aifast.club/v1/responses, no /v1/v1/responses

Minimal verification task

First start in strict configuration mode in the temporary directory:

codex --strict-config

After confirming that there are no unknown field errors on startup, run in the Codex:

Create a hello.txt,The content is connection ok,then show git diff。

Verify four things:

  1. Codex recognizes models.
  2. The request fell to the expected /v1/responses, did not become /v1/v1/responses
  3. Tool calls can return normally.
  4. The scope of file modification is consistent with the task.

FAQ

Unsupported parameter or response field is missing

This usually means that the compatibility layer does not fully implement the Responses API, rather than a prompt word issue. Save the error text and check the API protocol.

Ordinary Q&A is successful, but tool execution fails.

Codex agent tasks rely on tool invocation events and continuous responses. Successful text generation can only prove that the basic request is available, but not that the complete proxy link is available.

Environment variable not found

From the same terminal where Codex was launched, execute:

test -n "$AIFAST_API_KEY" && echo "Key Loaded"

Do not output the complete Key.

Next step

After completing the basic configuration, continue pressingCodex gateway API acceptance and troubleshooting checklistVerify actual Provider, Responses paths, streaming events, tool calls, context compression, and session recovery. Don't replace code agent acceptance with a plain text answer.

Before using a production repository, test read-only analysis, single-file edits, multi-file edits, and test commands. Keep the previous provider configuration ready for rollback.

  • Check current models and prices: View AIFast model prices, confirm that the target model currently supports the Responses API.
  • Create a standalone test key: Register AIFast, first limit the quota and start with read-only tasks.
Source checked

Reference and Check Sources

Next step

Check the model and price first, then create an independent test Key

The model ID, open status and price will change; it will be added to production after passing small-scale verification.

Model PricingCreate Account View API documentation