Point any OpenAI client at Tokex.

One endpoint for every listed model. Your agents hold their own credit, trade for exactly what they are short, and stop at the cap you set.
  1. 1Mint a key

    Sign in to the app and create an API key under Keys. It starts with tk_, carries only the scopes you give it, and is shown once: Tokex stores a hash.

  2. 2Point your client at Tokex

    Any OpenAI SDK works unchanged against /v1. Every write carries an Idempotency-Key, so a retry never runs twice.

  3. 3Set a cap

    A cap is a refusal, not a warning: the request that would cross it never reaches a provider. Set one per key or for the whole account.

import OpenAI from "openai"; const tokex = new OpenAI({  baseURL: `${process.env.TOKEX_URL}/v1`,  apiKey: process.env.TOKEX_KEY, // a tk_ key: inference scope, its own cap}); const res = await tokex.chat.completions.create(  {    model: "auto", // the cheapest model your credit covers    messages: [{ role: "user", content: "Draft release notes from this diff." }],    max_tokens: 800,  },  { headers: { "Idempotency-Key": crypto.randomUUID() } },); console.log(res.choices[0].message.content);console.log(res.tokex); // the receipt: model, usage, credit reserved and charged

The receipt, res.tokex

{  "model": "gpt-5",  "asset": "openai:gpt-5",  "usage": { "inputTokens": 212, "outputTokens": 478 },  "reservedCredits": "1728",  "charged": "690",  "cached": false,  "latencyMs": 1840,  "txId": "tx_01J9ZM2Q8K"}

Illustrative figures. The worst case is reserved before the call; what the answer did not use returns. A failed provider call returns the whole hold.

Autopilot picks the price.

Ask for model auto, or auto with a tier. Every candidate is priced through the live pools, and the cheapest one your credit covers runs.

auto:fast

llama-70b on the demo book

Short, cheap work: triage, extraction, summaries of logs.

auto:balanced

gpt-5 on the demo book

The default for most agent steps.

auto:frontier

claude-opus-5 on the demo book

The hard calls: reviews, plans, long reasoning.

allowSwap lets autopilot buy exactly the shortfall of a cheaper model, and needs the trade scope. Failover retries the next candidate when a provider breaks, which is safe because a failed call returns its whole hold. The response names the choice and the saving in a routing block.

Tools for agents, over MCP.

A stdio server that is a client of the HTTP API, holding no state of its own. Writes take an operationKey: the same key returns the first result and never runs twice.

tokex_ensure_credit

Enough of a model’s credit for N more calls of a given size? If not, it trades a holding for exactly the shortfall and says what it did. Checked, not reserved.

trades

tokex_complete

Runs inference and burns credit. A model name, or auto and auto:<tier> for the cheapest one at the live price.

spends

tokex_swap

Trades one credit for another. minOut, the floor, is required.

trades

tokex_quote

Prices a swap between two credits without running it.

reads

tokex_plan

What autopilot would choose for a request of this size, cheapest first. Runs nothing.

reads

tokex_operation_status

What happened to an operation, by its key. Use it after a lost reply, before any retry.

reads

tokex_balance

Balances for this key’s account, per credit. Amounts are strings.

reads

tokex_portfolio

Holdings valued in a reference credit and in US cents; anything unpriceable is flagged, not counted as zero.

reads

tokex_budget

Spend limits, spend so far, what is left, and when each window rolls.

reads

tokex_rates

Live rates between credits, quoted on a probe trade.

reads

tokex_models

Models this account can run, with their tier and per-token credit cost.

reads

An MCP client's config

{  "mcpServers": {    "tokex": {      "command": "node",      "args": ["/path/to/tokex/src/mcp.ts"],      "env": {        "TOKEX_MCP_STDIO": "1",        "TOKEX_API_URL": "https://your-tokex-host",        "TOKEX_API_KEY": "tk_..."      }    }  }}

The server runs from a checkout of the engine. The key's scopes decide which tools can move credit.

Endpoints.

JSON over HTTPS with a Bearer credential. Amounts are strings, never JSON numbers, so nothing rounds on the way.

Inference

POST/v1/chat/completionsOpenAI’s messages in; choices and usage out, plus a tokex receipt.
GET/v1/planAutopilot’s choice for a request, priced, without running it.
GET/v1/modelsModels you can run, with tier and credit cost.

Market

GET/v1/quotePrice a trade: amount out, impact, fees per leg.
POST/v1/swapTrade, with a floor. Final once it runs.
GET/v1/poolsPools and their reserves.
GET/v1/ratesRates between every pair of credits.

Wallet

GET/v1/balanceBalances per credit.
GET/v1/portfolioHoldings valued in a reference credit and in USD.
GET/v1/purchases/quoteWhat a card purchase buys, with the load fee.

Limits and safety

POST/v1/budgetsSet a spend cap for the account or one key.
POST/v1/panicRevoke every other key and freeze money movement. Reads stay open.
POST/v1/unfreezeLift an owner freeze, with a credential created after it.

Automation

POST/v1/ordersA standing order: buy at or below a price, or sell at or above one.
POST/v1/agents/deployDeploy an automation under its own key and its own cap.

Public, no key

GET/v1/indexThe Tokex Index now.
GET/v1/index/historyThe Index as a stored series.

When it says no.

Every refusal has a status and a stable code. Caps and freezes refuse before any provider sees the request, so a refusal costs nothing.

400invalid_requestMalformed input, or a write without an Idempotency-Key.
401unauthorizedNo credential, or one Tokex does not recognise.
402insufficient_fundsNot enough of that credit.
402budget_exceededThe request would cross a cap. Refused before any provider saw it.
403forbiddenThe key lacks the scope for this action.
403session_requiredOnly an owner session can do this, such as revoking another key.
409slippage_exceededThe pool moved past your floor. Nothing traded.
409insufficient_liquidityThe pool cannot fill that size.
423account_frozenThe account is frozen. Reads still answer.
429rate_limitedToo many requests. Back off, then retry with the same Idempotency-Key.

Prices your agents trade at are on Prices; what each call and trade costs is on Fees.

Get in
early.

Tokex runs on demo credit today. Leave an email and we will write when there is a seat for your agents.

Tokex will email you your place in line, your invite and launch news. Unsubscribe anytime. PrivacyTokex, 55 Erskine Ave, Suite 1201, Toronto ON M4P 1Y7, Canada, hello@tokex.dev