Quickstart

The Token Broker speaks the OpenAI API. Point any OpenAI-compatible SDK at our base URL with a tb_… key from the console. Every request is routed to the cheapest healthy offer and settled per token.

curl
export TB_API_KEY="tb_…"

curl https://api.thetokenbroker.ai/v1/chat/completions \
  -H "Authorization: Bearer $TB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5","messages":[{"role":"user","content":"hello"}]}'
python · openai sdk
from openai import OpenAI

client = OpenAI(
    base_url="https://api.thetokenbroker.ai/v1",
    api_key="tb_…",
)

r = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "price check"}],
    stream=True,
)
for chunk in r:
    print(chunk.choices[0].delta.content or "", end="")
node · openai sdk
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.thetokenbroker.ai/v1",
  apiKey: "tb_…",
});

const r = await client.chat.completions.create({
  model: "deepseek-v4-pro",
  messages: [{ role: "user", content: "hello" }],
});

Authentication

All inference endpoints take a bearer key: Authorization: Bearer tb_…. Keys are created in the console, shown once, and stored hashed. Each key can carry a monthly budget, a per-minute rate limit, and a model allowlist.

Models & pricing

The canonical registry is frontier labs only — Anthropic, OpenAI, Google, DeepSeek, Moonshot, xAI, Zhipu. GET /v1/models returns live buyer-effective prices (all-in, spread included) and the number of live offers per model. Public prices: /markets.

FieldMeaning
pricing.input_per_m_usdAll-in price per 1M input tokens
pricing.output_per_m_usdAll-in price per 1M output tokens
live_offersHealthy offers currently live

Chat completions

POST /v1/chat/completions — drop-in compatible. Streaming via SSE is supported and usage is always reported on the terminal chunk.

  • Up to 3 routing attempts per request; failover happens only before the first token.
  • Cost is reserved before the request and settled from actual usage after it completes.
  • 10s connect timeout, 60s first-token timeout.

Embeddings

POST /v1/embeddings follows the same shape. Embeddings capacity depends on sellers listing it — check /v1/models for what's live.

Response headers

HeaderMeaning
x-tb-request-idEvery request's permanent audit id
x-tb-price-microExact charge in micro-USD (non-streaming)
x-tb-tierThe price band that filled — never the seller
x-tb-modelCanonical model id that served the request

Errors

CodeWhen
insufficient_credits402 — fund the account in the console
budget_exceeded402 — the key's monthly budget is spent
rate_limit_error429 — per-key RPM ceiling; raise it in the console
no_capacity503 — no healthy offers for the model right now
upstream_error502 — every candidate offer failed; retry

Billing & credits

Credits are prepaid inference entitlements purchased by card. They're non-transferable, never redeemable for cash, and expire after 12 months of inactivity. Canadian buyers are charged GST/HST; non-resident businesses are zero-rated with a tax ID on file. Refunds go back to the original card only, within 24 hours of purchase, for the unused portion. Full terms: Terms of Service.

Limits & budgets

  • Top-ups: $10–$200 per transaction for accounts under 30 days old, $2,000 after.
  • Per-key monthly budgets and RPM limits are set in the console.
  • Reservations hold estimated cost for up to 5 minutes; the unused remainder releases automatically.

Seller API

Sellers manage endpoints and offers from the console, and every console action has a JSON API under /api/seller/*. Applications are reviewed within 48 hours. See /sell for tiers and rules.

  • POST /api/seller/apply — open an application
  • POST /api/seller/endpoints — connect an allowlisted upstream
  • POST /api/seller/offers — list an offer at your price
  • POST /api/seller/offers/:id/reprice — version your price
  • GET /api/seller/earnings — pending, held, available, paid