Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

9Router ×ばつ B.AI

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


Why

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.

What it does

  1. Derives the CLI token from ~/.9router/machine-id + ~/.9router/auth/cli-secret (the same mechanism the 9router CLI uses).
  2. Creates a provider node (openai-compatible type) pointing at https://api.b.ai/v1 — or reuses it if one with the same prefix already exists.
  3. Creates a provider connection with your B.AI API key — or skips it if already connected.
  4. Tests the connection against the first model in the list.
  5. Registers models (deepseek-v4-flash, deepseek-v4-pro by default) into the dashboard's Available Models.
  6. Verifies that models appear on the router's /v1/models under your prefix.

Requirements

  • Linux with bash 5+, curl, sha256sum, python3
  • A running 9Router instance (http://127.0.0.1:20128 by default)
  • Read access to the 9Router data directory (~/.9router, root or the user that runs 9Router)

Usage

git clone https://github.com/<you>/9router-bai-setup.git
cd 9router-bai-setup
./setup.sh --api-key sk-your-bai-key

Which API 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.

Options

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

Example — register extra models

./setup.sh --api-key sk-xxx \
 --models deepseek-v4-flash,deepseek-v4-pro,glm-5.2 \
 --name "B.AI" --prefix bai

Safety

  • 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-run shows exactly what will happen.
  • No secrets are logged — the API key is only sent over the local HTTP call.

What you get

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"

License

MIT

Disclaimer

This project is not affiliated with B.AI or 9Router. Use at your own risk — always dry-run in a test environment first.

About

One-command, zero-restart registration of B.AI as an OpenAI-compatible provider on 9Router (idempotent, 5-language README)

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /