Connect HiAPI to your agent
Choose your tool and model, copy the configuration, and start locally.
codex --versionInstallation guide01Save the configuration file
Create hiapi.config.toml in the .codex folder in your home directory, paste the configuration below, and save. Create the folder if needed.
~/.codex/hiapi.config.toml~ means your home directory; .codex is a hidden folder inside it.
Already have this file?
Leave config.toml unchanged. If hiapi.config.toml already exists, update its top-level model, model_provider, and the fields in [model_providers.hiapi]. Preserve other settings; do not duplicate keys or tables.
model_provider = "hiapi"
model = "deepseek-v4.1-flash"
[model_providers.hiapi]
name = "HiAPI"
base_url = "https://api.hiapi.ai/v1"
env_key = "HIAPI_API_KEY"
wire_api = "responses"
02Set your API key in the terminal
Open a terminal (bash / zsh), replace YOUR_HIAPI_API_KEY with your key, then run the command below. Do not put this command in the configuration file.
Manage API Keysexport HIAPI_API_KEY="YOUR_HIAPI_API_KEY"03Start your agent in the same terminal
In the terminal where you set the key, change to your project directory and run the command below. It loads hiapi.config.toml and preserves your default configuration.
Set the key again when opening a new terminal. After starting the agent, send a message and check your request logs.
codex --profile hiapiAfter starting, send this in the same Agent conversation:
Reply with only HIAPI_OK. Do not read or modify files.After receiving the text, check request logs for the model and status; copying this prompt does not prove a connection.
No reply?
Check your API Key, request logs, model, and CLI version first. Reasoning models may take longer; do not blindly set a very low output limit, force reasoning off, or change existing configuration.
Prepare your API Key
Create a Key in the console, then add it locally as shown in the config.
Manage API KeysConfirm the connection with one message
Start the Agent, send a message, then check the request log. Test calls use the model’s normal pricing.
View request logs