CanalAPI

Set up Codex

Configure a CanalAPI provider on Windows, macOS, and Linux, verify the Responses API, and troubleshoot common errors.

1. Gather your connection details

You need an API key, available account credit, and a model ID suitable for Codex. The model must support Responses, streaming, and tool calls. A working Chat Completions request alone does not establish Codex compatibility. Read model selection first.

SettingValue used here
Provider IDcanalapi
Base URLhttps://api.canalapi.com/v1
Wire APIresponses
Key variableCANALAPI_API_KEY
ConfigurationYour user's .codex/config.toml

2. Install and configure the CLI

Install and check the version

Use the official Codex CLI instructions. Skip installation if you already have it; avoid installing multiple copies.

Windows PowerShell

powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

macOS, Linux, WSL

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Open a new terminal and check:

codex --version

Back up and edit the configuration

Open the file in your home directory, not the shared C:\Users directory or a project's .codex folder.

  • Windows: %USERPROFILE%\.codex\config.toml, typically C:\Users\YourName\.codex\config.toml.
  • macOS / Linux: ~/.codex/config.toml.
  • If you explicitly set CODEX_HOME, use config.toml in that directory.

Create the directory and file if missing; avoid a hidden .txt extension. Back up an existing file. Merge the following fields and preserve unrelated settings rather than replacing the whole file.

model = "YOUR_CODEX_MODEL_ID"
model_provider = "canalapi"
web_search = "disabled"

[model_providers.canalapi]
name = "CanalAPI"
base_url = "https://api.canalapi.com/v1"
wire_api = "responses"
env_key = "CANALAPI_API_KEY"
requires_openai_auth = false

Replace YOUR_CODEX_MODEL_ID with an available model ID confirmed in the console. Keep model, model_provider, and web_search before the first [table]. Edit existing keys or the existing canalapi table instead of duplicating them. Start with web search disabled; enable additional features after confirming model and gateway support.

Custom aliases may also need matching Codex model metadata. Do not invent a model_catalog_url or a nonexistent file path. If Codex reports missing model metadata, consult the official gateway guide and support.

Set the key and check file access

Keep the key in an environment variable, outside TOML. Choose your shell's syntax and launch Codex from the same terminal.

Key created dialog with Copy key, Copy API URL, and setup guides; key redacted

Copy the key and API URL separately from the creation dialog. This is a local test-user screenshot with the key redacted. Codex keeps /v1 in its Base URL, matching the displayed address.

Windows PowerShell

$env:CANALAPI_API_KEY = "YOUR_CANALAPI_KEY"
codex

macOS, Linux, WSL (Bash / Zsh)

export CANALAPI_API_KEY="YOUR_CANALAPI_KEY"
codex

env_key names the variable; it does not contain the credential itself. Do not overwrite another application's credentials with a CanalAPI key.

Normal configuration does not require granting CodexSandboxUsers or another group full control of this file. For file-access failures, check the owning user and path and follow the official Windows setup guidance. Expanding file or tool permissions does not fix API authentication.

Verify your first request

  1. Run /status in the interactive session and check provider and model. If old settings remain active, inspect project overrides, CLI flags, the selected profile, and organization policies.
  2. Ask “Reply only OK, without reading or modifying files.” This sends a real, potentially billable model request.
  3. Match the model, time, and status in usage logs before trying a project task.
  4. If it fails, use the Responses example to distinguish endpoint, model, key, and client configuration issues.

3. Desktop apps and persistent variables

See the official app documentation. A desktop application typically does not inherit variables set in a separate terminal. CLI success does not automatically verify the desktop application's connection.

After a successful temporary test, Windows users can save the current variable to their own user environment:

[Environment]::SetEnvironmentVariable('CANALAPI_API_KEY', $env:CANALAPI_API_KEY, 'User')

Fully quit and restart the terminal, IDE, or desktop application so its new process reads the environment; signing out of the OS may be necessary. On macOS / Linux, shell configuration affects shells that load it; follow the app's documented environment setup for desktop use. Never commit the key or send it in a support request.

4. Troubleshooting and rollback

SymptomWhat to check
Missing environment variableExact env_key spelling and whether the launching process inherited the variable
TOML parsing errorDuplicate keys/tables, smart quotes, or top-level keys accidentally placed inside a table
404 / unsupported endpointExactly one /v1 in the base URL, and a model supporting Responses
401 / 402 / 403Check credentials, balance, and spending limits separately in troubleshooting
Conversation works but tools failCheck tool-calling support, streaming compatibility, and client version; retain the request ID

Restore the backup or remove only the provider fields you added, then restart. Do not delete the entire .codex directory or existing login files. Sources: CLI installation, gateway setup, configuration layers. Reviewed on 2026-11-03.

On this page