Codex CLI

Nội dung tài liệu kỹ thuật hiện được cung cấp bằng tiếng Anh.

Codex CLI connects to Uptech API as a custom provider using OpenAI Responses. Use https://api.uptech.vn/v1 as the base URL; requests go to /v1/responses.

Copy from a model detail

Open the Model Catalog, select a model, and choose Quick start → Codex CLI. Choose Temporary command for one run or Configuration file for the persistent config.toml setup. The model ID is filled in automatically.

A model with only Chat Completions or Messages does not qualify for this configuration. Quick start requires Responses in the model's published protocols. You must also verify streaming and tool calls for your coding task.

Install

npm install -g @openai/codex
codex --version

See the official Codex CLI guide for platform installation details.

1. Temporary command

Use this when you only need the Uptech API provider for the current invocation. Create a key in Workspace → API Keys, then replace the placeholder before running the command.

macOS / Linux

export APIGO_API_KEY='YOUR_APIGO_API_KEY'

codex --model 'YOUR_MODEL_ID' \
  -c 'model_provider="apigo"' \
  -c 'model_providers.apigo.name="Uptech API"' \
  -c 'model_providers.apigo.base_url="https://api.uptech.vn/v1"' \
  -c 'model_providers.apigo.env_key="APIGO_API_KEY"' \
  -c 'model_providers.apigo.wire_api="responses"'

Windows PowerShell

$env:APIGO_API_KEY = 'YOUR_APIGO_API_KEY'

codex --model 'YOUR_MODEL_ID' `
  -c 'model_provider="apigo"' `
  -c 'model_providers.apigo.name="Uptech API"' `
  -c 'model_providers.apigo.base_url="https://api.uptech.vn/v1"' `
  -c 'model_providers.apigo.env_key="APIGO_API_KEY"' `
  -c 'model_providers.apigo.wire_api="responses"'

This command only overrides the current invocation. The selected model must support Uptech API Responses.

2. Configuration file

Create or edit ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml). Replace YOUR_MODEL_ID with the exact Uptech API model ID:

model = "YOUR_MODEL_ID"
model_provider = "apigo"

[model_providers.apigo]
name = "Uptech API"
base_url = "https://api.uptech.vn/v1"
env_key = "APIGO_API_KEY"
wire_api = "responses"

Put model and model_provider at the top level, before any [table]. Merge the provider block with an existing apigo block instead of duplicating it. Preserve unrelated settings. Do not put the key in TOML.

wire_api = "chat" from older instructions is not the configuration for this guide. Do not combine env_key with [model_providers.apigo.auth]; choose one credential mechanism. The example uses only env_key. See the official provider configuration.

Set the API key

Create a key in Workspace → API Keys, then replace the placeholder.

macOS / Linux

export APIGO_API_KEY='YOUR_APIGO_API_KEY'

Windows PowerShell

$env:APIGO_API_KEY = 'YOUR_APIGO_API_KEY'

Run Codex from the same terminal. To persist the variable, add the assignment to ~/.zshrc, ~/.bashrc, or PowerShell $PROFILE, then reopen the terminal. Keep actual credentials out of repository files.

Start and switch models

codex --model 'YOUR_MODEL_ID'

Override the saved model for a new session:

codex --model 'ANOTHER_MODEL_ID'

The override changes the model, not the provider. Select another model that supports Uptech API Responses. Check the active provider if a project configuration or previously selected profile changes your defaults.

Optional: a separate Uptech API profile

On versions using file-based profiles, save the same configuration block in ~/.codex/apigo.config.toml instead of changing your default provider. Then run:

codex --profile apigo

The profile overlays ~/.codex/config.toml. Older versions may use a different profile format; consult the configuration documentation for your installed version instead of mixing formats. The default config.toml setup above does not require a profile. Profile reference.

3. Verify the request

Ask Codex to summarize the current directory without changing files. In Nhật ký gọi API, check the selected model, final status, and usage. Next, use a disposable project to verify a tool call, its returned result, and a complete streamed answer. An HTTP 200 or a first token alone does not prove the full workflow completed.

Troubleshooting

Symptom Check
Missing APIGO_API_KEY or 401 The variable must exist in the terminal launching Codex; verify the key's status.
Duplicate key / invalid TOML Merge fields instead of appending another provider block; keep top-level fields outside tables.
404 / protocol error Base URL must include /v1, but not /responses; use wire_api = "responses".
Model unavailable Exact ID, Responses protocol, API-key model permissions, and Workspace availability.
Requests go elsewhere Đang hoạt động model_provider, project settings, and any selected profile. You do not need to delete other providers' credentials.
Tool or stream failure Inspect the failed request. Increasing a timeout does not implement missing Responses events or tool support.

Do not enable model-specific reasoning, search, or context options unless the selected route supports them.

Related: Claude Code · Model Catalog · Usage and logs.