One API. A cap on every request.
Cross AI speaks the OpenAI Chat Completions API. Change the base URL and the key; everything else in your code stays the same.
Quickstart live
- Open the Playground: sign in, get USDG, deposit and set a spending limit (four steps, about a minute).
- Create an API key under Account → API keys.
- Call the API with any OpenAI SDK:
curl https://ai.crossmind.lat/v1/chat/completions \
-H "Authorization: Bearer $CROSS_AI_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "auto", "messages": [{"role": "user", "content": "Hello"}], "max_cost": "0.01"}'Authentication live
Send Authorization: Bearer cm_test_…. A key belongs to a wallet and spends from that wallet’s spending limit. Each key can also have its own limits: per request, per day (UTC), per month and in total, plus an expiry. The smallest one applies, and a request that could go over it is shortened or not sent. Up to 20 active keys per wallet. The website signs you in with Sign-In with Ethereum and an HttpOnly cookie; managing money and keys needs that sign-in, not a key.
Models live
GET /v1/models lists every model with its provider, prices per million input and output tokens (USDG), context length, data handling and reliability measured by the gateway over 7 days (provisional under 20 requests). The Models page shows the same list.
Chat completions live
POST /v1/chat/completions with the usual fields: model, messages, max_tokens, temperature, stream. Cross AI adds, at the top level or in extra_body:
model | A model id, or a policy: auto, cheapest, balanced, fastest, best. |
max_cost | USDG, such as "0.01". The most this request may cost. Replies are shortened to fit; if even a short reply could cost more, the request is not sent. |
route | The policy when model is auto. |
fallback | Try the next model if one fails. On by default for policies, off for a named model. |
The reply is a standard chat completion plus a cross object:
"cross": {
"receipt": "fa6ed248db614c7489f3df29",
"model": "llama-3.1-8b-fast",
"route": "auto",
"charge": "0.000021", // USDG
"max_cost_held": "0.000051", // reserved while it ran
"tokenizer": "provider-reported",
"prices_per_mtok": { "input": "0.045000", "output": "0.384000" },
"provider_total": "0.000021", // owed to this provider in total
"voucher": { "buyer": "0xca94…48e3", "provider": "0x4850…17d0", "sequence": 1, "cumulative": "21", "deadline": 1797204840, "signature": "0x927a…" },
"latency_ms": 330
}Routing and limits live
auto reads your message: code goes to a coding model, maths to a reasoning model, long inputs to a long-context model, short chat to a fast small model. cheapest ranks by the cost of a typical reply, fastest by speed, best by quality, balanced weighs all three. Models failing more than 40% of recent requests are skipped. The charge is input tokens × input price + output tokens × output price, per million, rounded up to the base unit, and never more than what was held.
Limits: 40 requests a minute per wallet. The reference provider runs on a limited Workers AI allowance, so heavy use may fail with all_providers_failed.
Streaming live
With stream: true you get standard chat.completion.chunk events. The last chunk before [DONE] carries usage and the cross receipt. Stopping early charges only what was written.
Receipts and usage live
GET /v1/receipts?limit=50 lists your latest receipts; GET /v1/receipts/:id adds the settlement state. GET /v1/usage?days=30 totals requests, tokens and charges by model and by day. Prompts and replies are not stored; receipts keep token counts and prices only.
Errors live
401 auth | Missing, malformed, revoked or expired key, or a key at its spending limit. |
402 no_limit | This wallet has not set a spending limit. Set one under Account. |
402 insufficient_limit | The request could cost more than is left of the spending limit. |
402 key_limit | The API key reached its per-day, per-month or total limit. |
402 max_cost_too_low | Even a short reply could cost more than max_cost. |
429 rate_limited | Too many requests this minute. |
502 all_providers_failed | No model could answer; nothing was charged. |
Payments and limits live
One deposit in the vault funds both markets. A spending limit sets part of it aside for AI (one transaction), for every model and every provider, with no expiry; after that you sign nothing per request. Before a request runs, the gateway holds its worst-case cost against what is left, so parallel requests can never go over the limit; afterwards the metering signer signs the new running total you owe that provider as an EIP-712 voucher. One Durable Object per wallet is the only writer of those totals.
The relayer submits the latest vouchers in batches once $1 or more is owed or the latest voucher is 10 minutes old. The spending-limit contract pays only the increase and never more than you set aside. Raising the limit is instant. Taking money back waits 10 minutes, so work already done is paid first, then returns it to Available; the relayer completes it for you. Withdrawals from Available are never paused.
Fees live
2% of each settled increase, taken from what the provider receives. The fee in force when usage is paid applies, and any change waits out the timelock. There is no fee to deposit, withdraw or take money back.
For providers live
The Providers page walks you through it with a form and writes the manifest for you. By hand: register in the registry, publish the keccak-256 hash of your manifest (canonical JSON, keys sorted), then run the checks. Prices are USDG base units (6 decimals) per million tokens. A manifest:
{
"schema": "crossmind.provider-manifest/1",
"provider": "0xYourWallet",
"name": "My provider",
"endpoint": "https://api.example.com/v1",
"dataPolicy": { "retention": "none", "training": false },
"models": [{ "id": "my-model", "inputPerMTok": "200000", "outputPerMTok": "600000", "contextLength": 32000 }]
}Checks: public HTTPS, an OpenAI-compatible reply, token usage reported, an answer within 20 s. Routing buyers to independent endpoints opens in the next release; the reference provider serves all traffic today.
Contracts live
Robinhood Chain, chain id 4663. Admin of every contract is a timelock (24 hours), and only a 2-of-3 multisig can schedule changes.
Safeguards
- The vault holds exactly what it owes: available balances plus what spending limits have set aside.
- Pausing stops new spending limits; it never stops withdrawals, payment of signed work or taking money back.
- No admin function can move a user’s balance. Fees have a hard cap in the contracts (10%).
- Vouchers carry a sequence number, so nothing can be paid twice, and never above the cap.
- API keys and sign-in tokens are stored only as hashes; prompts and replies are not stored.