AI Hub CLI (aihub)
Unified zero-proxy launcher (belive-aihub) for running Claude Code, Codex CLI, DeepSeek Harness, OpenCode, and Antigravity CLI (agy >= 1.5.0, experimental) directly against AI Hub on macOS and Linux.
aihub connects each client directly to AI Hub's native routes (https://tokenhub-api.belive.sg/api/v1) with zero local proxy. Your ordinary claude, codex, dsh, opencode, and agy commands keep their existing vendor logins. On Windows, run inside WSL2 or follow the manual guides in Coding agents.
Prerequisites
- OS: macOS or Linux (WSL2 on Windows)
- Runtime: Node.js
>= 22.0.0(DeepSeek Harnessdshitself requires Node.js>= 24.9.0) - AI Hub key: A dedicated workspace inference key (
sk-tokenhub-…) with a monthly spend cap - Client CLI: At least one supported coding agent installed on
PATH(claude,codex,dsh,opencode, oragy >= 1.5.0)
1. Install and configure
Manual install
Install belive-aihub globally from npm (provides the aihub command):
npm install -g belive-aihub aihub --version
Save your workspace key to ~/.aihub/credentials.json (mode 0600) and open the keys page if you need a new key:
aihub setup --openFor CI or shell scripts, export BELIVE_TOKENHUB_API_KEY instead of storing a file:
export BELIVE_TOKENHUB_API_KEY="sk-tokenhub-…"Let an AI agent set it up
Paste this prompt into an existing coding agent session to install and verify aihub:
Install belive-aihub globally under Node.js 22+ (`npm install -g belive-aihub`), verify `aihub --version`, and run `aihub doctor` (do not print any API keys). Report which agent CLIs are ready on PATH and any warnings.2. Commands at a glance
Every command supports -h / --help. Arguments after the first client-specific flag are forwarded verbatim to the underlying CLI.
| Command | What it does | Example | Key options |
|---|---|---|---|
aihub setup | Save or clear a 0600 workspace key in ~/.aihub/credentials.json | aihub setup --open | --open, --clear |
aihub doctor | Check credentials, installed CLIs, settings conflicts, routes, and model retirements | aihub doctor --smoke | --smoke, --base-url <origin> |
aihub models | List or search live catalogue model IDs, context lengths, prices, and retirement status | aihub models deepseek | [<search>], --json, --base-url <origin> |
aihub config | Inspect, initialize, or override per-harness default models and effort in ~/.aihub/config.json | aihub config init | show, init [--force], set <key> <val>, unset <key> |
aihub claude | Launch Claude Code against AI Hub's Messages route | aihub claude --model <author/slug> | --model <id>, --effort low|medium|high|max |
aihub codex | Launch Codex CLI in an isolated CODEX_HOME over Responses | aihub codex --effort medium | --model <id>, --effort low|medium|high|xhigh |
aihub dsh | Launch DeepSeek Harness in an isolated DSH_HOME over Chat Completions | aihub dsh headless "List scripts" | --model <id>, --effort <level> |
aihub opencode | Launch OpenCode with runtime OPENCODE_CONFIG_CONTENT | aihub opencode run "Explain README" | --model <id>, --base-url <origin> |
aihub agy | Launch Antigravity CLI (experimental, requires agy >= 1.5.0) | aihub agy --model <author/slug> | --model <id>, --effort low|medium|high|xhigh |
3. Finding and setting model IDs
Every AI Hub model ID uses the exact author/slug format shown in Models. You can discover and filter live model IDs right from the terminal without an API key:
aihub models aihub models qwen aihub models deepseek --json
Precedence: where model IDs and effort are resolved
- Command-line flag (
--model <id>,--effort <level>) — highest priority, applies to that single run. - User config file (
~/.aihub/config.json, managed viaaihub config) — persistent per-harness override. - Built-in adapter default — used whenever neither a flag nor a config override is set.
Setting persistent defaults (aihub config)
Create a commented ~/.aihub/config.json template (JSONC — // and /* */ comments are supported) or set individual keys from the CLI:
aihub config init aihub config set opencode.model deepseek/deepseek-v4-pro aihub config set dsh.model qwen/qwen3.8-max aihub config set dsh.effort off aihub config show
To revert a key back to the built-in default:
aihub config unset dsh.effortPer-launcher model ID samples
| Launcher | One-off override | Persistent default | Where the adapter applies it |
|---|---|---|---|
aihub claude | aihub claude --model <author/slug> --effort high | aihub config set claude.model <author/slug> | Pins all roles when set; leaves tiered built-in roles active when unset. --effort sets CLAUDE_CODE_EFFORT_LEVEL only when explicitly provided. |
aihub codex | aihub codex --model <author/slug> --effort high | aihub config set codex.model <author/slug> | Passes -m and -c model_reasoning_effort=... on top of static ~/.aihub/codex/prod/config.toml. |
aihub dsh | aihub dsh --model qwen/qwen3.8-max --effort off headless "Summarise README" | aihub config set dsh.model qwen/qwen3.8-max | Writes a temporary 0600 --patch overlay on top of ~/.aihub/dsh/prod/cordis.patch.yml (registers new catalogue IDs automatically). |
aihub opencode | aihub opencode --model deepseek/deepseek-v4-pro | aihub config set opencode.model deepseek/deepseek-v4-pro | Sets "model" and "small_model" to "tokenhub/<id>" inside runtime OPENCODE_CONFIG_CONTENT. |
aihub agy (experimental) | aihub agy --model <id> --effort high | aihub config set agy.model <id> | Passes --model and optional --effort alongside session-only agy --settings. |
For client-specific tested models and protocol limits, see Claude Code, Codex CLI, DeepSeek Harness, OpenCode, and Antigravity CLI. If your workspace key has a model allowlist guardrail, ensure the exact author/slug is permitted on that key in API keys.
4. Common workflows
Diagnostics and health checks
| Task | Command | Notes |
|---|---|---|
| Read-only local + gateway check | aihub doctor | Checks platform, key hygiene, installed CLIs, settings conflicts, public route discovery, and retiring_on notices |
| Live authenticated smoke check | aihub doctor --smoke | Opt-in tiny request across gateway routes (under USD 0.01) |
| Check against a custom gateway origin | aihub doctor --base-url <origin> | Requires BELIVE_TOKENHUB_API_KEY in the environment |
Launching coding agents
| Task | Command | Notes |
|---|---|---|
| Start an interactive session | aihub claude / aihub codex / aihub dsh / aihub opencode / aihub agy | Uses saved config.json overrides or built-in adapter defaults |
| Run a one-shot DeepSeek Harness task | aihub dsh --model qwen/qwen3.8-flash --effort off headless "Summarise package.json" | Defaults to dsh tui when no profile (tui, headless, web) is given |
| Forward native client flags | aihub claude -- -p "Reply OK" | Everything after -- (or the first non-wrapper flag) goes straight to the client |
5. Environment variables and files
Credential resolution follows this exact order:
| Priority | Source | Scope | Notes |
|---|---|---|---|
| 1 | BELIVE_TOKENHUB_API_KEY | Environment variable | Recommended for CI and scripts; avoids clashing with other tools using TOKENHUB_API_KEY |
| 2 | ~/.aihub/credentials.json | Local 0600 file (aihub setup) | Refused if group/world-readable; never sent to a custom --base-url or AIHUB_BASE_URL |
| 3 | TOKENHUB_API_KEY | Fallback environment variable | Used only when 1 and 2 are unset and the value starts with sk-tokenhub- |
Additional configuration files and environment overrides:
| Name | Default | Behavior |
|---|---|---|
~/.aihub/config.json | (optional) | Mode 0600 JSONC file storing per-harness model and effort defaults (aihub config init) |
AIHUB_BASE_URL | https://tokenhub-api.belive.sg/api/v1 (origin) | Overrides the gateway origin for all commands (overridden by --base-url <origin>) |
AIHUB_HOME | ~/.aihub | Overrides where aihub stores credentials.json, config.json, isolated CODEX_HOME, and DSH_HOME |
6. Isolation, security, and billing
| Launcher | Isolation mechanism | Shares harness state? | Security & state notes |
|---|---|---|---|
aihub claude | Child env + non-secret --settings <json> override | Yes — ~/.claude/ | Refuses on managed/project auth overrides and user secret helpers; MDM policy is not locally inspectable |
aihub codex | Static per-env CODEX_HOME (~/.aihub/codex/prod) + -m / -c flags | No — ignores ~/.codex | Safe across concurrent sessions with different --model or --effort flags |
aihub dsh | Static per-env DSH_HOME (~/.aihub/dsh/prod/cordis.patch.yml) + per-launch 0600 --patch | No — ignores ~/.deepseek-harness | Unsets DEEPSEEK_API_KEY so web-search plugins never send keys outside AI Hub |
aihub opencode | Runtime OPENCODE_CONFIG_CONTENT referencing {env:BELIVE_TOKENHUB_API_KEY} | Yes — leaves opencode.json untouched | Routes tokenhub/<author/slug> over Chat Completions without writing raw keys to disk |
aihub agy (experimental) | Session-only agy --settings on real HOME (agy >= 1.5.0) | Yes — ~/.gemini/antigravity-cli | Never persists provider overrides to settings.json; merges caller --settings safely |
- Child environment boundary: Wrapped agents inherit the resolved key in their process environment (
ANTHROPIC_AUTH_TOKEN,BELIVE_TOKENHUB_API_KEY,GEMINI_API_KEY), so shell commands or local MCP servers run by the agent can read it. Always use a dedicated workspace key with a spend cap. - Billing source of truth: Console Activity is the source of truth for billed spend across all CLIs. A client CLI's own cost estimate is not AI Hub's charge.
7. Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Credential file … has insecure permissions | ~/.aihub/credentials.json is group- or world-readable | Run chmod 600 ~/.aihub/credentials.json |
Custom --base-url requires BELIVE_TOKENHUB_API_KEY | Stored credentials are never sent to custom origins | Export BELIVE_TOKENHUB_API_KEY in the shell |
Unsupported Antigravity CLI ('agy') version | Installed agy is older than 1.5.0 | Run agy update and retry |
agy probe timed out on first run after update | macOS Gatekeeper verifying a newly updated binary | Retry once, or run agy --version directly |
dsh fails to boot on Node 22 | DeepSeek Harness requires Node.js >= 24.9.0 | Ensure Node.js >= 24.9.0 is first on PATH when invoking aihub dsh |
401 or 403 from AI Hub | Wrong environment key, revoked key, or model not on key allowlist | Check API keys and run aihub doctor --smoke |