API Reference

TokenBridge API Reference

All live endpoints with curl samples, response shapes, EUR pricing, and rate-limit notes. Base URL: https://tokenbridge-zoos.polsia.app/api/proxy for the proxy gateway; https://tokenbridge-zoos.polsia.app/api for account endpoints.

01Authentication

Every request to the proxy gateway and account endpoints requires a TokenBridge API key passed as a Bearer token.

bashAuthorization: Bearer tb_live_xxxxxxxxxxxxxxxxxxxx

API keys are prefixed tb_live_. Obtain yours at /signup or from your dashboard.

Rate-limit response headers

Every proxy response includes these headers:

HeaderDescription
X-RateLimit-LimitMaximum requests per 60-second window (currently 100)
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetUnix timestamp (seconds) when the current window resets
🔒

The proxy gateway (/api/proxy/v1/...) accepts Bearer header only. The account endpoints (/api/usage/..., /api/keys/...) accept a tb_session cookie or Bearer header.


02POST/api/proxy/v1/chat/completions

OpenAI-compatible chat completions endpoint. Supports streaming via SSE. Deducts from your EUR wallet on every successful call.

Request

bashcurl https://tokenbridge-zoos.polsia.app/api/proxy/v1/chat/completions \
  -H "Authorization: Bearer tb_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "Hello, world!"}]
  }'

Request body

FieldTypeRequiredDescription
modelstringYesModel ID (see table below). OpenAI aliases gpt-4o, gpt-4o-mini, gpt-3.5-turbo map to deepseek-chat.
messagesarrayYesArray of { role, content } objects. At least one message required.
streambooleanNoSet to true to receive a Server-Sent Events stream. Billing still applies.
temperature, top_p, max_tokens, ...anyNoStandard OpenAI chat parameters are forwarded to the upstream provider as-is.

Supported models

ModelInput (€/1M tokens)Output (€/1M tokens)Provider
deepseek-chat€0.18€0.36DeepSeek
deepseek-reasoner€0.44€0.88DeepSeek
doubao-pro-32k€0.14€0.37ByteDance Volcano
doubao-lite-32k€0.10€0.28ByteDance Volcano
qwen-max€2.06€8.26Alibaba DashScope
qwen-plus€0.51€1.55Alibaba DashScope
qwen-turbo€0.13€0.39Alibaba DashScope

Sample response (non-streaming)

json{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1750000000,
  "model": "deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 9,
    "total_tokens": 19
  }
}

Rate limit

100 requests/minute per API key. Exceeding the limit returns HTTP 429 with a retryAfterMs field indicating the milliseconds until the window resets.

Error codes

401 Unauthorized
Missing or invalid API key. Ensure the key starts with tb_live_ and is active.
402 Payment Required
EUR wallet balance is zero or insufficient. Top up at /buy.
404 Not Found
Unknown model ID. Check /models for the supported list.
429 Too Many Requests
Rate limit exceeded. Inspect retryAfterMs and back off before retrying.
502 Bad Gateway
Upstream provider (DeepSeek/ByteDance/Alibaba) returned an error. Retry with exponential backoff.
5xx Internal
Server-side error. Contact support if the issue persists.

03GET/api/proxy/v1/models

Lists all supported models in OpenAI-compatible format. Auth required (no billing deduction).

bashcurl https://tokenbridge-zoos.polsia.app/api/proxy/v1/models \
  -H "Authorization: Bearer tb_live_YOUR_KEY"

Sample response

json{
  "object": "list",
  "data": [
    {
      "id": "deepseek-chat",
      "object": "model",
      "created": 1748260000,
      "owned_by": "deepseek"
    },
    {
      "id": "deepseek-reasoner",
      "object": "model",
      "created": 1748260000,
      "owned_by": "deepseek"
    }
  ]
}

The data array contains all 7 supported models. Pass the id field verbatim as the model in chat completions requests.


04GET/api/me/usage

Returns current wallet balance and the last 50 usage events for the authenticated API key. Auth: Bearer tb_live_... header only (no cookie).

bashcurl https://tokenbridge-zoos.polsia.app/api/me/usage \
  -H "Authorization: Bearer tb_live_YOUR_KEY"

Sample response

json{
  "balance_eur_cents": 4800,
  "balance_eur": "48.00",
  "usage": [
    {
      "model": "deepseek-chat",
      "input_tokens": 250,
      "output_tokens": 180,
      "cost_usd": 0,
      "created_at": "2026-07-25T14:32:10.000Z"
    }
  ]
}

The usage array contains rows from the legacy usage_log table. For the canonical EUR-denominated ledger with reasoning_tokens and eur_cost, use GET /api/usage/history.


05GET/api/usage/history

Itemised per-call rows from the canonical usage_events ledger with full EUR cost data. Auth: tb_session cookie or Bearer header.

Query parameters

ParamFormatDefaultDescription
fromYYYY-MM-DDInclusive start date (UTC). Omit for unbounded.
toYYYY-MM-DDInclusive end date (UTC). Omit for unbounded.
limitinteger500Max rows per page (hard cap: 1000).
offsetinteger0Row offset for pagination.
bashcurl "https://tokenbridge-zoos.polsia.app/api/usage/history?from=2026-07-01&to=2026-07-25&limit=100" \
  -H "Authorization: Bearer tb_live_YOUR_KEY"

Sample response

json{
  "rows": [
    {
      "created_at": "2026-07-25T14:32:10.000Z",
      "model": "deepseek-chat",
      "input_tokens": 250,
      "output_tokens": 180,
      "reasoning_tokens": 0,
      "eur_cost": 0.0001098,
      "eur_cents": 0,
      "request_id": "req_abc123",
      "status": "completed"
    }
  ],
  "total": {
    "count": 1,
    "total_eur": 0.0001098,
    "eur_cents": 0,
    "eur": "0.00"
  },
  "from": "2026-07-01",
  "to": "2026-07-25",
  "limit": 100,
  "offset": 0
}

06GET/api/usage/export.csv

Downloads usage as a CSV attachment. Same auth as /history. Capped at 10,000 rows per export.

Query parameters

ParamFormatDescription
fromYYYY-MM-DDInclusive start date
toYYYY-MM-DDInclusive end date
bashcurl "https://tokenbridge-zoos.polsia.app/api/usage/export.csv?from=2026-07-01&to=2026-07-25" \
  -H "Authorization: Bearer tb_live_YOUR_KEY" \
  -o usage.csv

CSV columns

ColumnDescription
timestampISO-8601 UTC call timestamp
endpointModel ID used for the call
prompt_tokensInput tokens billed
completion_tokensOutput tokens billed
reasoning_tokensReasoning tokens (deepseek-reasoner only, billed at output rate)
credits_eurEUR cost deducted (6 decimal places)
request_idOpaque request identifier for support queries
statusAlways completed for billed rows

07Dashboard usage endpoints

These endpoints power the dashboard UI. Auth: tb_session cookie or Bearer header. Not typically called by production integrations directly.

PathParamsResponse summary
GET /api/usage/recent limit (max 200, default 50) { usage: [...] } — last N calls from usage_log
GET /api/usage/daily days (max 90, default 30) { daily: [...] } — EUR cents per day per model for the stacked bar chart
GET /api/usage/current none { used, limit, pct } — current-month spend vs wallet balance (wallet card progress bar)
GET /api/usage/topups limit (max 50, default 20) { topups: [...] } — last N Stripe wallet top-ups

08POST/api/keys/rotate

Rotates your API key. The old key is invalidated immediately; requests using it will return 401 after rotation. Auth: tb_session cookie or Bearer header.

bashcurl -X POST https://tokenbridge-zoos.polsia.app/api/keys/rotate \
  -H "Authorization: Bearer tb_live_YOUR_KEY"

Response

json{
  "apiKey": "tb_live_YOURNEWKEYHERE"
}
⚠️

Copy the new key immediately. It is returned only once and cannot be retrieved again. Update any integrations before the old key stops working.


09EUR pricing reference

All costs are deducted from your EUR wallet per call, atomically, rounded up to the nearest EUR cent. No subscriptions, no expiry on credits.

ModelInput (€/1M tokens)Output (€/1M tokens)Notes
deepseek-chat€0.18€0.36
deepseek-reasoner€0.44€0.88Reasoning tokens billed at output rate
doubao-pro-32k€0.14€0.37
doubao-lite-32k€0.10€0.28
qwen-max€2.06€8.26
qwen-plus€0.51€1.55
qwen-turbo€0.13€0.39

For deepseek-reasoner, reasoning_tokens are billed at the same rate as output tokens. Cost formula: (input_tokens / 1M × input_rate) + ((output_tokens + reasoning_tokens) / 1M × output_rate), rounded up to nearest cent.

A low-balance email alert fires when your wallet drops below €5. Top up at /buy or from your wallet page.


10/invoices — billing history

The /invoices page lists your Stripe-backed billing history. Auth: session (cookie or Bearer). No API endpoint — rendered as an HTML page from the dashboard.

PathAuthDescription
GET /invoicesSessionLists all invoices, newest first (up to 100 rows)
GET /invoices/:id/download.pdfSessionDownloads a branded PDF for the given invoice row. The :id is the internal database row ID shown in the invoice list.
💡

Invoice rows appear after the Stripe checkout.session.completed webhook fires. PDF invoices are generated locally (not Stripe-hosted) and include your company billing details.