BBToken

API Documentation

Base URLhttps://bandelbanget.xyz/v1

Quickstart (OpenCode)

One command to set up OpenCode with your provider API key. It installs OpenCode if it is missing, fetches the model list with your key, and writes ~/.config/opencode/opencode.json.

terminal
BASE_URL="https://bandelbanget.xyz/v1" API_KEY="sk-..." bash <(curl -fsSL https://bbtoken.cloud/docs/linux.sh)

When it finishes, the script prints how many models it found and the default model, then: Now run: opencode.

Prefer to write the config yourself? Create ~/.config/opencode/opencode.json with one entry per model from /v1/models, then run opencode.

~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bbtoken": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://bandelbanget.xyz/v1",
        "apiKey": "sk-..."
      },
      "models": {
        "glm-5.2": {
          "name": "glm-5.2",
          "modalities": {
            "input": [
              "text"
            ],
            "output": [
              "text"
            ]
          }
        }
      }
    }
  },
  "model": "bbtoken/glm-5.2",
  "permission": "allow"
}

Claude Code

Claude Code speaks the Anthropic /v1/messages API and adds /v1/messages to the base URL itself, so set the bare origin https://bandelbanget.xyz, without /v1.

install
npm install -g @anthropic-ai/claude-code
environment
export ANTHROPIC_BASE_URL="https://bandelbanget.xyz"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="glm-5.2"

Or keep the settings in ~/.claude/settings.json. The haiku, sonnet, and opus tiers can each point at a model from the catalog:

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://bandelbanget.xyz",
    "ANTHROPIC_AUTH_TOKEN": "sk-...",
    "ANTHROPIC_MODEL": "glm-5.2",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash-0731",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3"
  }
}

Then run claude.

Hermes Agent

Hermes Agent (NousResearch) uses the OpenAI /v1/chat/completions API.

install
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash

Run hermes model, choose "Custom endpoint", and enter the base URL, your API key, and a model. Or write ~/.hermes/config.yaml directly:

~/.hermes/config.yaml
model:
  default: glm-5.2
  provider: custom
  base_url: https://bandelbanget.xyz/v1
  api_key: sk-...

Then run hermes, or hermes chat.

9Router

9Router is a self-hosted, OpenAI-compatible gateway. Add BBToken as an upstream provider, then point your tools at 9Router.

install
npm install -g 9router
9router
  • Open the dashboard at http://localhost:20128/dashboard.
  • Go to Providers, Add/Connect, and pick the custom OpenAI-compatible endpoint.
  • Enter the base URL https://bandelbanget.xyz/v1 and your API key. Models come from /v1/models.
  • Point your coding tool at http://localhost:20128/v1 with the API key shown in the 9Router dashboard.

Authentication

Every request needs an Authorization: Bearer sk-... header with the provider API key from the API Key Vault in your dashboard, available after you buy a token package.

header
Authorization: Bearer sk-your-provider-key

Older BBToken keys (sk-bbt-...) keep working on https://bbtoken.cloud/v1, so existing setups need no change.

Endpoints

POST/v1/chat/completionsCreate a chat completion (OpenAI-compatible). Supports streaming via stream: true.
GET/v1/modelsList available models with multiplier, grade, and vision capability.
GET/v1/quotaCheck your remaining token quota, usage percent, and expiry.
POST/v1/messagesAnthropic Messages API compatibility. This is the endpoint Claude Code calls.
POST/v1/responsesOpenAI Responses API compatibility.

Chat Completion Example

curl
curl -X POST https://bandelbanget.xyz/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": false
  }'

Non-stream requests must finish within 90 seconds. For long answers add "stream": true: streams stay open while the model is thinking because the proxy sends a keepalive comment every 15 seconds.

Streaming Example

curl
curl -X POST https://bandelbanget.xyz/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }'

Streaming responses include a final chunk with usage data (prompt_tokens, completion_tokens, total_tokens).

List Models

curl
curl https://bandelbanget.xyz/v1/models \
  -H "Authorization: Bearer sk-..."

Response includes model id, cluster, multiplier, grade, and vision capability for each available model.

Check Quota

curl
curl https://bandelbanget.xyz/v1/quota \
  -H "Authorization: Bearer sk-..."

Error Codes

401unauthorizedMissing or invalid API key.
402key_active_no_quotaAPI key is active but has no token quota. Top up to start using.
404model_not_foundRequested model is not available or not visible.
500server_errorInternal server error. Try again or contact support.
502upstream_disconnectedThe provider closed the connection mid-response. Safe to retry.
504upstream_headers_timeoutThe provider did not start responding within 90 seconds. Safe to retry.
504non_stream_timeoutA non-stream request passed 90 seconds. Retry with stream: true.
429rate_limitedToo many requests. Slow down.

Model Multiplier

Multiplier is a token consumption factor per model. Default is 1x (tokens counted 1:1). If a model has multiplier 1.5x, each token consumed counts 1.5x against your quota.

formula
Formula: (prompt_tokens + completion_tokens) x multiplier = tokens deducted

Model Grade

  • Grade ATop quality from well-known services.
  • Grade BLimited performance, new or small services.
  • Grade CBudget choice, low performance but cheaper.

Quota & Validity

  • Package validity is 28 days from first API request.
  • If validity expires, quota is preserved. Top up any package to reactivate.
  • Remaining old quota accumulates with new quota on top up.
  • One API key works across multiple devices and IDEs simultaneously.

Rate Limits

  • No hard rate limit per customer on chat completions.
  • Streaming: the proxy sends a keepalive comment every 15 seconds and closes the stream after 90 seconds without data.
  • Non-stream: 90 seconds per request. Use stream: true for long generations.
  • Model catalogue without an API key: 60 requests per minute per IP.
  • Quota API: reasonable use, avoid polling faster than once per minute.

Compatible Tools

  • OpenCode1-click setup via quickstart script above.
  • Claude CodeSet ANTHROPIC_BASE_URL to the origin without /v1, plus ANTHROPIC_AUTH_TOKEN. See the Claude Code section above.
  • Hermes Agent, 9RouterCustom OpenAI-compatible endpoint. See their sections above.
  • Cursor, VS Code (Cline, Roo Code, Continue), Windsurf, JetBrainsSet custom OpenAI Base URL.