Usage
Codex CLI
How to use the Ahur API in the Codex CLI — the automatic route with the Ahur CLI and the manual route
Using Ahur in the Codex CLI
The Codex CLI is a command-line coding tool from OpenAI built on the Responses API. There are two ways to use it with Ahur.
Option 1 (recommended): use the Ahur CLI
The simplest route — the Ahur CLI installs, configures and launches the Codex CLI for you:
# install the Ahur CLI
npm install -g ahur-cli
# set your API key
ahur config set api_key ak_your_key_here
# run the Codex CLI through Ahur
ahur launch codex
The Ahur CLI automatically:
- Installs the Codex CLI if it isn't already present
- Adds the Ahur provider settings to
~/.codex/config.toml - Sets the
AHUR_API_KEYenvironment variable and starts the Codex CLI
Resuming a previous conversation
ahur launch codex --resume sess_abc123
Choosing a specific model
ahur launch codex --model ahur/general
Option 2: manual setup
If you'd rather work with the Codex CLI directly:
1. Get an API key
- Go to the API keys section of the developer panel.
- Create a new key and store it somewhere safe.
2. Install the Codex CLI
npm install -g @openai/codex
3. Configure the Ahur provider
Create the file ~/.codex/config.toml:
[model_providers.ahur]
name = "Ahur"
base_url = "https://api.ahur.ir/v1"
env_key = "AHUR_API_KEY"
4. Set the environment variable
export AHUR_API_KEY="ak_your_key_here"
To make this permanent, add it to ~/.bashrc or ~/.zshrc:
echo 'export AHUR_API_KEY="ak_your_key_here"' >> ~/.bashrc
source ~/.bashrc
5. Run it
codex -c 'model="ahur/general"' -c 'model_provider="ahur"'
You can use any model available on Ahur. See the full list with
ahur launch --help or on the pricing page.Security notes
- Never share your API key with anyone
- Track your consumption and costs in the usage statistics section
- The
~/.codex/config.tomlfile stores your provider settings