How to set up Codex CLI with a 5abeer API key
Add 5abeer as a provider in Codex CLI's config.toml, save your key in one environment variable and run GPT models at about 70% below the official price.
On this page
- What you get
- Before you start
- With a subscription: the 5abeer AI app
- Manual setup
- Install Codex CLI
- Add the settings
- Run it
- Pick a model
- If you get an error
- Questions
- Do I need a ChatGPT or OpenAI account?
- Why does Codex say the key is missing?
- What does wire_api = "responses" do?
- How is a request billed?
- Sources
To run Codex CLI with 5abeer, install Codex, add a khabeer provider with the 5abeer base URL to ~/.codex/config.toml, and save your 5abeer API key in the KHABEER_API_KEY environment variable. Then run codex in your project; every request is paid from your 5abeer balance. With a subscription, the 5abeer AI app does this setup for you.
What you get#
- Codex CLI exactly as it ships, with its commands and settings.
- The GPT models 5abeer serves, at about 70% below their official price.
- Usage and cost per key in your dashboard.
Before you start#
- A terminal on macOS, Linux or Windows.
- An API key for GPT models (create one).
With a subscription: the 5abeer AI app#
If you have a 5abeer subscription that includes Codex, the 5abeer AI app sets it up on your subscription for you, with no API key and no files to edit. The app runs on Mac, Windows and Linux; details in What each plan runs. With an API key, follow the manual setup below.
Manual setup#
Install Codex CLI#
Run the official installer for your system:
curl -fsSL https://chatgpt.com/codex/install.sh | shIf you have Node.js, you can install it with npm instead, or with Homebrew on macOS:
npm install -g @openai/codexAdd the settings#
Put these settings in
~/.codex/config.toml. Codex reads the key from theKHABEER_API_KEYenvironment variable, so save your key there with the tab for your system.model = "gpt-6.1-sol" model_provider = "khabeer" [model_providers.khabeer] name = "5abeer" base_url = "https://api.5abeer.ai/v1" env_key = "KHABEER_API_KEY" wire_api = "responses"~/.codex/config.toml
The terminal commands above set the key only in the current terminal. To keep it in every new terminal, save it once:
echo 'export KHABEER_API_KEY="YOUR_5ABEER_API_KEY"' >> ~/.zshrcThen open a new terminal. The saved key only reaches terminals you open after saving it.
Pick a model#
These models run in Codex today. Change the model line in the config file, or pick a model inside Codex with /model.
GPT-6.1 SolInput$0.60Output$3Context922K
GPT-6 AstraInput$3Output$15Context—
GPT-6 SolInput$0.60Output$3Context922K
GPT-6 LunaInput$0.03Output$0.15Context922K
GPT-5.6 LunaInput$0.06Output$0.36Context400K
GPT-5.6 TerraInput$0.60Output$3.60Context400K
GPT-5.6 SolInput$1.20Output$6Context400K
GPT-5.5Input$1.50Output$9Context1.05M
GPT-5.4 MiniInput$0.23Output$1.35Context400K
Official price from the provider's page, checked October 19, 2026.
All models and pricesIf you get an error#
INVALID_API_KEY: the key is wrong, or the environment variable isn't set in the terminal you started Codex from.MODEL_PLATFORM_NOT_ALLOWED: the key belongs to a provider other than GPT.INSUFFICIENT_BALANCE: your balance doesn't cover this request.RATE_LIMITED: too many requests in a short time.
Every code and what it means is in Errors and fixes.
Questions#
Do I need a ChatGPT or OpenAI account?#
No. The khabeer provider in the config reads your 5abeer key from KHABEER_API_KEY, so Codex sends that key and you don't sign in to OpenAI.
Why does Codex say the key is missing?#
The variable isn't set in the terminal that started Codex. Set it again, or save it permanently and open a new terminal, then run codex again.
What does wire_api = "responses" do?#
It makes Codex send requests in the OpenAI Responses format, which 5abeer serves for GPT models. It's the only value Codex supports, and the default if you leave the line out. Details in the Responses reference.
How is a request billed?#
Each request is paid from your balance by the tokens it uses, at the model's 5abeer price. Details in Pricing and balance.
Sources#
Checked on 2026-11-01:
- Codex CLI repository: openai/codex
- Codex docs: Configuration Reference
- Microsoft Learn: setx
Was this page helpful?