Unlock the potential of Codex CLI with Zeabur AI Hub
The Codex CLI is a powerful interface for interacting with AI in your terminal. However, locking yourself into a single provider limits your potential.
By connecting the Codex CLI to Zeabur AI Hub, you can route your queries to any top-tier model (like Claude, Grok, or Gemini) using the exact same tool. This setup works on a pay-as-you-go basis—no need to juggle multiple subscriptions for different AI providers.
Here is how to set it up.
Install Codex CLI:
npm install -g @openai/codex
Zeabur Credentials:
Choose your Endpoint
Zeabur currently provides two endpoints. Pick the one geographically closest to you:
https://hnd1.aihub.zeabur.ai/https://sfo1.aihub.zeabur.ai/You need to configure Codex to talk to Zeabur's unified API instead of a specific provider directly.
Create or edit the config file at ~/.codex/config.toml. Paste the following configuration to define Zeabur as a provider:
# Default model to use
model = "gemini-3-pro-preview"
model_provider = "zeabur"
[model_providers.zeabur]
name = "Zeabur AI Hub"
# Note: Ensure you append /v1 to the endpoint
base_url = "<https://hnd1.aihub.zeabur.ai/v1>"
env_key = "ZEABUR_API_KEY"
wire_api = "chat"
You need to make your API key available to the tool.
Option A: Just trying it out (Temporary)
For a single session usage:
export ZEABUR_API_KEY="your-zeabur-api-key"
codex "Who are you?"
Option B: Set it and forget it (Permanent)
To avoid setting the key every time, add it to your shell profile.
Open your shell configuration (e.g., ~/.zshrc or ~/.bashrc):
nano ~/.zshrc
Paste this line at the bottom:
export ZEABUR_API_KEY="your-zeabur-api-key"
Save and reload: source ~/.zshrc
Now you can use the CLI tool with the flexibility to switch models on the fly.
Basic Usage:
codex "Write a hello world function in Python"
Switching Models:
You can override the default model defined in your config using the -m flag.
# Use Gemini
codex -m gemini-3-pro-preview "hi"
# Use Claude
codex -m claude-sonnet-4-20250514 "hi"
# Use GPT-4o
codex -m gpt-4o "hi"
Why this is better:
If you run into issues:
base_url in your config includes /v1.echo $ZEABUR_API_KEY.gpt-4o) is currently supported by Zeabur AI Hub. Check the Zeabur dashboard for the list of available model IDs.Happy Coding!