9Router ×ばつ B.AI Auto Setup
×ばつ B.AI Auto Setup" href="#9router--bai-auto-setup">One-command, zero-restart registration of B.AI as an OpenAI-compatible provider on your running 9Router instance.
License: MIT Version Platform Bash 9Router Model
Read this in: English · Bahasa Indonesia · 简体中文 · 日本語 · Español
9Router's web dashboard normally requires a browser login, and wiring a custom OpenAI-compatible provider by hand means clicking through the UI. This script does it via 9Router's internal CLI API — no browser login, no SQLite surgery, no process restart. The provider appears on the dashboard and is immediately routable.
It is idempotent: run it once, run it ten times — it detects what already exists and skips it.
- Derives the CLI token from
~/.9router/machine-id+~/.9router/auth/cli-secret(the same mechanism the9routerCLI uses). - Creates a provider node (
openai-compatibletype) pointing athttps://api.b.ai/v1— or reuses it if one with the same prefix already exists. - Creates a provider connection with your B.AI API key — or skips it if already connected.
- Tests the connection against the first model in the list.
- Registers models (
deepseek-v4-flash,deepseek-v4-proby default) into the dashboard's Available Models. - Verifies that models appear on the router's
/v1/modelsunder your prefix.
- Linux with
bash5+,curl,sha256sum,python3 - A running 9Router instance (
http://127.0.0.1:20128by default) - Read access to the 9Router data directory (
~/.9router, root or the user that runs 9Router)
git clone https://github.com/<you>/9router-bai-setup.git cd 9router-bai-setup ./setup.sh --api-key sk-your-bai-key
--api-key is your B.AI API key — created at the B.AI dashboard (https://api.b.ai), format sk-.... It is the upstream key for the provider being registered.
It is not:
- the 9Router API key / "Default Key" — that's the key apps use to talk to 9Router's
/v1; the script never needs it - any Hermes / OpenAI / other key
The script additionally needs read access to ~/.9router/machine-id and ~/.9router/auth/cli-secret to derive 9Router's internal CLI token — run it as root or as the same user that runs 9Router.
| Option | Default | Description |
|---|---|---|
--api-key KEY |
$BAI_API_KEY |
B.AI API key (required) |
--base-url URL |
https://api.b.ai/v1 |
Provider endpoint |
--prefix PREFIX |
bai |
Model prefix on 9Router (bai/deepseek-v4-flash) |
--name NAME |
B.AI DeepSeek |
Provider display name in dashboard |
--models LIST |
deepseek-v4-flash,deepseek-v4-pro |
Comma-separated models to register |
--router-url URL |
http://127.0.0.1:20128 |
9Router dashboard URL |
--router-home DIR |
$HOME/.9router |
9Router data directory |
--dry-run |
off | Show planned actions without executing |
--quiet |
off | Only print errors |
./setup.sh --api-key sk-xxx \
--models deepseek-v4-flash,deepseek-v4-pro,glm-5.2 \
--name "B.AI" --prefix bai- Never restarts 9Router — all changes go through the HTTP API of the already-running process.
- Dry-run first:
./setup.sh --api-key sk-xxx --dry-runshows exactly what will happen. - No secrets are logged — the API key is only sent over the local HTTP call.
| Dashboard | http://<host>:20128/dashboard/providers shows the new connection |
| Router API | GET /v1/models exposes bai/deepseek-v4-flash, bai/deepseek-v4-pro, and the rest of B.AI's 39 models |
| Chat | POST /v1/chat/completions with model: "bai/deepseek-v4-flash" |
This project is not affiliated with B.AI or 9Router. Use at your own risk — always dry-run in a test environment first.