Guides

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 Harness dsh itself 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, or agy >= 1.5.0)

1. Install and configure

Manual install

Install belive-aihub globally from npm (provides the aihub command):

bash
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:

bash
aihub setup --open

For CI or shell scripts, export BELIVE_TOKENHUB_API_KEY instead of storing a file:

bash
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:

text
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.

CommandWhat it doesExampleKey options
aihub setupSave or clear a 0600 workspace key in ~/.aihub/credentials.jsonaihub setup --open--open, --clear
aihub doctorCheck credentials, installed CLIs, settings conflicts, routes, and model retirementsaihub doctor --smoke--smoke, --base-url <origin>
aihub modelsList or search live catalogue model IDs, context lengths, prices, and retirement statusaihub models deepseek[<search>], --json, --base-url <origin>
aihub configInspect, initialize, or override per-harness default models and effort in ~/.aihub/config.jsonaihub config initshow, init [--force], set <key> <val>, unset <key>
aihub claudeLaunch Claude Code against AI Hub's Messages routeaihub claude --model <author/slug>--model <id>, --effort low|medium|high|max
aihub codexLaunch Codex CLI in an isolated CODEX_HOME over Responsesaihub codex --effort medium--model <id>, --effort low|medium|high|xhigh
aihub dshLaunch DeepSeek Harness in an isolated DSH_HOME over Chat Completionsaihub dsh headless "List scripts"--model <id>, --effort <level>
aihub opencodeLaunch OpenCode with runtime OPENCODE_CONFIG_CONTENTaihub opencode run "Explain README"--model <id>, --base-url <origin>
aihub agyLaunch 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:

bash
aihub models
aihub models qwen
aihub models deepseek --json

Precedence: where model IDs and effort are resolved

  1. Command-line flag (--model <id>, --effort <level>) — highest priority, applies to that single run.
  2. User config file (~/.aihub/config.json, managed via aihub config) — persistent per-harness override.
  3. 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:

bash
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:

bash
aihub config unset dsh.effort

Per-launcher model ID samples

LauncherOne-off overridePersistent defaultWhere the adapter applies it
aihub claudeaihub claude --model <author/slug> --effort highaihub 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 codexaihub codex --model <author/slug> --effort highaihub config set codex.model <author/slug>Passes -m and -c model_reasoning_effort=... on top of static ~/.aihub/codex/prod/config.toml.
aihub dshaihub dsh --model qwen/qwen3.8-max --effort off headless "Summarise README"aihub config set dsh.model qwen/qwen3.8-maxWrites a temporary 0600 --patch overlay on top of ~/.aihub/dsh/prod/cordis.patch.yml (registers new catalogue IDs automatically).
aihub opencodeaihub opencode --model deepseek/deepseek-v4-proaihub config set opencode.model deepseek/deepseek-v4-proSets "model" and "small_model" to "tokenhub/<id>" inside runtime OPENCODE_CONFIG_CONTENT.
aihub agy (experimental)aihub agy --model <id> --effort highaihub 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

TaskCommandNotes
Read-only local + gateway checkaihub doctorChecks platform, key hygiene, installed CLIs, settings conflicts, public route discovery, and retiring_on notices
Live authenticated smoke checkaihub doctor --smokeOpt-in tiny request across gateway routes (under USD 0.01)
Check against a custom gateway originaihub doctor --base-url <origin>Requires BELIVE_TOKENHUB_API_KEY in the environment

Launching coding agents

TaskCommandNotes
Start an interactive sessionaihub claude / aihub codex / aihub dsh / aihub opencode / aihub agyUses saved config.json overrides or built-in adapter defaults
Run a one-shot DeepSeek Harness taskaihub 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 flagsaihub 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:

PrioritySourceScopeNotes
1BELIVE_TOKENHUB_API_KEYEnvironment variableRecommended for CI and scripts; avoids clashing with other tools using TOKENHUB_API_KEY
2~/.aihub/credentials.jsonLocal 0600 file (aihub setup)Refused if group/world-readable; never sent to a custom --base-url or AIHUB_BASE_URL
3TOKENHUB_API_KEYFallback environment variableUsed only when 1 and 2 are unset and the value starts with sk-tokenhub-

Additional configuration files and environment overrides:

NameDefaultBehavior
~/.aihub/config.json(optional)Mode 0600 JSONC file storing per-harness model and effort defaults (aihub config init)
AIHUB_BASE_URLhttps://tokenhub-api.belive.sg/api/v1 (origin)Overrides the gateway origin for all commands (overridden by --base-url <origin>)
AIHUB_HOME~/.aihubOverrides where aihub stores credentials.json, config.json, isolated CODEX_HOME, and DSH_HOME

6. Isolation, security, and billing

LauncherIsolation mechanismShares harness state?Security & state notes
aihub claudeChild env + non-secret --settings <json> overrideYes — ~/.claude/Refuses on managed/project auth overrides and user secret helpers; MDM policy is not locally inspectable
aihub codexStatic per-env CODEX_HOME (~/.aihub/codex/prod) + -m / -c flagsNo — ignores ~/.codexSafe across concurrent sessions with different --model or --effort flags
aihub dshStatic per-env DSH_HOME (~/.aihub/dsh/prod/cordis.patch.yml) + per-launch 0600 --patchNo — ignores ~/.deepseek-harnessUnsets DEEPSEEK_API_KEY so web-search plugins never send keys outside AI Hub
aihub opencodeRuntime OPENCODE_CONFIG_CONTENT referencing {env:BELIVE_TOKENHUB_API_KEY}Yes — leaves opencode.json untouchedRoutes 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-cliNever 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

SymptomLikely causeFix
Credential file … has insecure permissions~/.aihub/credentials.json is group- or world-readableRun chmod 600 ~/.aihub/credentials.json
Custom --base-url requires BELIVE_TOKENHUB_API_KEYStored credentials are never sent to custom originsExport BELIVE_TOKENHUB_API_KEY in the shell
Unsupported Antigravity CLI ('agy') versionInstalled agy is older than 1.5.0Run agy update and retry
agy probe timed out on first run after updatemacOS Gatekeeper verifying a newly updated binaryRetry once, or run agy --version directly
dsh fails to boot on Node 22DeepSeek Harness requires Node.js >= 24.9.0Ensure Node.js >= 24.9.0 is first on PATH when invoking aihub dsh
401 or 403 from AI HubWrong environment key, revoked key, or model not on key allowlistCheck API keys and run aihub doctor --smoke