Docs
Everything needed to switch, pick a grade, verify, and get paid back.
Quickstart
Base URL https://bestex.dev/v1 (OpenAI-shaped) or https://bestex.dev for Anthropic-shaped clients. Key: sk-bx-… from Account.
curl https://bestex.dev/v1/chat/completions \
-H "Authorization: Bearer $BESTEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"bestex/grade/anthropic/claude-fable-5.1","messages":[{"role":"user","content":"hi"}]}'Grade
Put grade in the model name and the request is billed at half of list: bestex/grade/<provider>/<model>. Leave it out and the exact model runs at list price.
| Model name | What you get | Price |
|---|---|---|
bestex/grade/… | Answered now. While the vault is funded, by the exact model you name (the vault pays the other half). Otherwise by a model matched to it, which may not be that exact model. | 50% of list |
bestex/… | The exact model you name, answered now. | List price at most |
| Batch | The exact model you name, answered later. | 50% of list |
Grade is offered on the models that show a Grade price on Models. On other models a Grade request returns half_not_available_for_model; stakers get half price on those too. The list price of the model you name is a ceiling on every request.
Checks (optional)
If you want an answer to meet a rule before you pay for it, add a bestex.verify object and use bestex/verified/…. Supported: json_schema, regex, contains, and judge (a rubric). Attempts that fail the check are not charged.
"bestex": { "verify": { "json_schema": { "type": "object", "required": ["city"] } } }Batch: the same model at half price
For work that can wait. A batch job runs on the model you name, from the same lab, and is billed at 50% of list. Results come back within 24 hours, usually in minutes. Models that support it show a batch price on Models; you can also send a job without code on Batch.
POST https://bestex.dev/v1/batches
{ "model": "anthropic/claude-fable-5.1",
"requests": [ { "custom_id": "a1", "body": { "messages": [{"role":"user","content":"…"}], "max_tokens": 800 } } ] }
→ 202 { "id": "bx-batch-…", "status": "validating", "held_usd": … }
GET https://bestex.dev/v1/batches/<id>
→ { "status": "completed", "charged_usd": …, "list_cost_usd": …,
"results": [ { "custom_id": "a1", "response": { "choices": [ … ] }, "error": null } ] }Up to 200 requests per job, each with a unique custom_id. When you submit, the worst case (every request using its full max_tokens, default 2000) is held from your balance; the unused part comes back when the job finishes. A request that fails inside a job is not charged. No streaming.
Refunds
A request that errors, times out (default 60 s) or returns an empty answer is not charged. The refund rate is on Status.
Feedback API
POST https://bestex.dev/v1/feedback
[{ "id": "<x-bestex-id>", "feedback": { "helpful": true, "rating": 4.5 }, "optimize": "max" }]Each event earns a small credit (default $0.002) and helps Grade pick better for that kind of task.
Credits & keys
Wallet: sign Bestex API key · chain 4663 · epoch N; the base64 signature is your key. GET /v1/key returns balance and limits. Buy credits on Credits: send USDG from the same wallet and the gateway credits it after reading the transfer on-chain (1 USDG = $1 of credit, no fee).
Staking
Stake $BESTEX and Grade works on every model: where no match exists, the model you name runs and you still pay half while the vault can cover it. Without staking, Grade is limited to a set number of requests a day (the gateway answers 429 grade_daily_limit_reached past it); stakers have no limit. Stakers also pay no margin and get a daily rebate on everything they spend. When the vault cannot cover a model that has no match, the request is billed at the normal price and x-bestex-grade says why. Opens at token launch.
Headers
x-bestex-id, x-bestex-grade, x-bestex-list-cost, x-bestex-charged, x-bestex-saved, x-bestex-balance, and x-bestex-app-fee for requests made through an app.
Streaming. Requests for the exact model stream straight from the provider; the cost fields then arrive as HTTP trailers and in a final SSE chunk {"bestex": {…}} just before [DONE], because the cost is only known when the answer ends. Grade requests are completed first, then streamed to you with all headers set.
Errors
401 bad key · 402 insufficient balance · 402 daily_cap_reached (agent budget policy) · 403 grade_not_allowed (budget policy) · 400 half_not_available_for_model (Grade is not offered on that model) · 422 request failed, refunded · 429 rate limit.