Point any OpenAI client at Tokex.
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.
2Point your client at Tokex
Any OpenAI SDK works unchanged against /v1. Every write carries an Idempotency-Key, so a retry never runs twice.
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 chargedThe 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.
tradestokex_complete
Runs inference and burns credit. A model name, or auto and auto:<tier> for the cheapest one at the live price.
spendstokex_swap
Trades one credit for another. minOut, the floor, is required.
tradestokex_quote
Prices a swap between two credits without running it.
readstokex_plan
What autopilot would choose for a request of this size, cheapest first. Runs nothing.
readstokex_operation_status
What happened to an operation, by its key. Use it after a lost reply, before any retry.
readstokex_balance
Balances for this key’s account, per credit. Amounts are strings.
readstokex_portfolio
Holdings valued in a reference credit and in US cents; anything unpriceable is flagged, not counted as zero.
readstokex_budget
Spend limits, spend so far, what is left, and when each window rolls.
readstokex_rates
Live rates between credits, quoted on a probe trade.
readstokex_models
Models this account can run, with their tier and per-token credit cost.
readsAn 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
Market
Wallet
Limits and safety
Automation
Public, no key
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.
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.