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.
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"}]}'
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="")
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" }], });
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.
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.
| Field | Meaning |
|---|---|
| pricing.input_per_m_usd | All-in price per 1M input tokens |
| pricing.output_per_m_usd | All-in price per 1M output tokens |
| live_offers | Healthy offers currently live |
| modalities.input | Verified input types; includes image for routes checked with real images |
| reasoning_levels | Confirmed selectable reasoning tiers, where available |
POST /v1/chat/completions — drop-in compatible. Streaming via SSE is supported and usage is always reported on the terminal chunk.
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.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.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:
"gpt-6.1-sol": {
"name": "GPT-6.1 Sol",
"attachment": true,
"modalities": { "input": ["text", "image"], "output": ["text"] }
}
POST /v1/embeddings follows the same shape. Embeddings capacity depends on sellers listing it — check /v1/models for what's live.
| Header | Meaning |
|---|---|
| x-tb-request-id | Every request's permanent audit id |
| x-tb-price-micro | Exact charge in micro-USD (non-streaming) |
| x-tb-tier | The price band that filled — never the seller |
| x-tb-model | Canonical model id that served the request |
| Code | When |
|---|---|
| insufficient_credits | 402 — fund the account in the console |
| budget_exceeded | 402 — the key's monthly budget is spent |
| rate_limit_error | 429 — per-key RPM ceiling; raise it in the console |
| no_capacity | 503 — no healthy offers for the model right now |
| upstream_error | 502 — every candidate offer failed; retry |
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.
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 setupPOST /api/seller/endpoints — connect an allowlisted upstreamPOST /api/seller/offers — list an offer at your pricePOST /api/seller/offers/:id/reprice — version your priceGET /api/seller/earnings — pending, held, available, paid