DOCS // FULL REFERENCE

API Documentation

Quickstart (OpenCode)

One command to configure OpenCode with your BBToken API key. Validates your key, fetches available models, and writes config automatically.

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

Terminal output: [BBToken] Fetching models... [BBToken] API key valid. 35 models available. [BBToken] Done. Run 'opencode' to start.

Authentication

Every request requires an Authorization: Bearer sk-bbt-... header. Get your API key from the dashboard after purchasing a token package.

Authorization: Bearer sk-bbt-yourkeyhere

Endpoints

POST
/v1/chat/completions
Create a chat completion (OpenAI-compatible). Supports streaming via stream: true.
GET
/v1/models
List available models with multiplier, grade, and vision capability.
GET
/v1/quota
Check your remaining token quota, usage percent, and expiry.

Chat Completion Example

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

Streaming Example

curl -X POST https://bbtoken.cloud/v1/chat/completions \
  -H "Authorization: Bearer sk-bbt-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "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 https://bbtoken.cloud/v1/models \
  -H "Authorization: Bearer sk-bbt-..."

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

Check Quota

curl https://bbtoken.cloud/v1/quota \
  -H "Authorization: Bearer sk-bbt-..."

Error Codes

401
unauthorized
Missing or invalid API key.
402
key_active_no_quota
API key is active but has no token quota. Top up to start using.
404
model_not_found
Requested model is not available or not visible.
500
server_error
Internal server error. Try again or contact support.
502
server_unavailable
Upstream provider unreachable. Try again.
429
rate_limited
Too 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: (prompt_tokens + completion_tokens) x multiplier = tokens deducted

Model Grade

  • Grade A — Top quality from well-known services.
  • Grade B — Limited performance, new or small services.
  • Grade C — Budget 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 timeout: 60 seconds per request.
  • Quota API: reasonable use, avoid polling faster than once per minute.

Compatible Tools

  • OpenCode — 1-click setup via quickstart script above.
  • Claude Code — Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.
  • Cursor, VS Code (Cline, Roo Code, Continue), Windsurf, JetBrains — Set custom OpenAI Base URL.