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
modalities.inputVerified input types; includes image for routes checked with real images
reasoning_levelsConfirmed selectable reasoning tiers, where available

Chat completions

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

  • Automatic failover happens only before the first token. Each attempt reserves its own price before contacting the provider.
  • Cost is reserved before the request and settled from actual usage after it completes.
  • Requests that omit max_tokens get 8,192 output tokens. Set max_tokens explicitly for more, up to 128,000, as long as the model's context window holds input plus output. Interrupted streams return an error.
  • GPT-5.6 Sol, GPT-6 Sol, GPT-6 Astra, GPT-6 Luna, and GPT-6.1 Sol support reasoning_effort values low, medium, high, xhigh, and max on their InferHub routes. The OpenCode setup includes these as variants via reasoningEffort. Higher effort may increase latency and token usage; availability depends on the upstream route.

Images & screenshots

Send images as OpenAI image_url content parts, using an HTTPS URL or a base64 data URL. GPT-6.1 Sol (gpt-6.1-sol) and Claude Sonnet 4.6 (claude-sonnet-4-6) passed our image check. Other routes are not yet vision-verified. Check current availability in /v1/models.

OpenCode custom models must explicitly declare image input. Without this, OpenCode can reject an attachment before sending it to Token Broker. The console's setup config includes these fields for verified models. Merge them into any existing model definition, then fully quit and restart OpenCode:

opencode.json · model entry
"gpt-6.1-sol": {
  "name": "GPT-6.1 Sol",
  "attachment": true,
  "modalities": { "input": ["text", "image"], "output": ["text"] }
}

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 purchased by card. Top-ups add the purchased credit amount after Stripe confirms payment, and a hosted invoice is created. Automatic Stripe Tax is currently disabled. Refund requests must be made within 24 hours of purchase for unused credits and are processed to the original payment method. Full terms: Terms of Service.

Limits & budgets

  • Top-ups: $10–$200 per transaction and $500 per 7 days for accounts under 30 days old, $2,000 per transaction 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 set up their account without an application. Verified email, a screened wallet, and account checks are required; two-factor authentication is optional but recommended. Listings check the allowlisted provider and run three verification prompts. T1 activates when checks pass; review-status providers also require terms approval. See seller tiers and payout holds.

  • POST /api/seller/start — begin self-serve setup
  • 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