Reseller API Reference
Automate your reseller account from your own backend. All amounts are in USD.
Authentication
Create a key in Re Sell → API & Webhooks. It starts with qbx_rs_. Keep it on your server only — it can manage all your customers.
BASE=https://api.qubax.ai/reseller/v1
curl $BASE/me -H "Authorization: Bearer qbx_rs_..."sk-…) make AI requests on your domain only.Endpoints
Trusted or untrusted providers
Each customer key has a providers setting:
- trusted (default) — verified providers only. Safer, usually costs more.
- untrusted — all providers, usually cheaper. They are not verified, so don't use it for private data.
The price is different for each. You pay our price for the provider that answers, and your customer pays that plus your margin. See both prices in GET /models (customerPrice and untrusted.customerPrice).
# new key on untrusted providers
curl -X POST $BASE/customers/$CUSTOMER_ID/keys -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"name":"Prod","providers":"untrusted"}'
# switch an existing key back to trusted
curl -X PATCH $BASE/customers/$CUSTOMER_ID/keys/$KEY_ID -H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" -d '{"providers":"trusted"}'Example: new customer after checkout
const BASE = "https://api.qubax.ai/reseller/v1";
const H = { Authorization: `Bearer ${process.env.QUBAX_RESELLER_KEY}`, "Content-Type": "application/json" };
// 1. create the customer
const c = await fetch(`${BASE}/customers`, { method: "POST", headers: H,
body: JSON.stringify({ name: "Acme Ltd", externalRef: stripeCustomer.id }) }).then(r => r.json());
// 2. give them a key (show it to them once). providers: "trusted" (default) or "untrusted"
const k = await fetch(`${BASE}/customers/${c.id}/keys`, { method: "POST", headers: H,
body: JSON.stringify({ providers: "trusted" }) }).then(r => r.json());
// 3. after every payment, add balance (safe to retry)
await fetch(`${BASE}/customers/${c.id}/credit`, { method: "POST",
headers: { ...H, "Idempotency-Key": payment.id },
body: JSON.stringify({ amountUsd: 20, note: "Stripe " + payment.id }) });Errors
Errors use { "error": { "message": "..." } } with status 400 (bad input), 401 (bad key), 403 (not approved / suspended), 404 (not found) or 429 (too many requests).
On your domain, customer requests fail with 402 when their balance or spend limit is used up, 403 when the customer is paused, and 503 when your credit is empty (so your customers never see a billing message about you).
Webhooks
We POST JSON to your URL. Events: customer.balance_low, customer.balance_depleted, customer.spend_limit_reached, reseller.credit_low, reseller.credit_depleted, domain.active, domain.failed. Failed deliveries are retried a few times.
{
"id": "evt_3f9c…",
"type": "customer.balance_low",
"created": 1790510400,
"data": {
"customer": { "id": "…", "external_ref": "cus_123", "name": "Acme Ltd", "billing_mode": "prepaid",
"balance_usd": 0.84, "spent_this_period_usd": 0, "spend_limit_usd": null }
}
}Verify every webhook. The signature is HMAC-SHA256 of `${timestamp}.${rawBody}` with your signing secret:
import crypto from "node:crypto";
function verify(req, rawBody, secret) {
const ts = req.headers["x-webhook-timestamp"];
const sig = req.headers["x-webhook-signature"];
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; // 5 min
const expected = crypto.createHmac("sha256", secret).update(`${ts}.${rawBody}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
}Ready to build?
380+ models through one OpenAI & Anthropic-compatible API, up to 99% below OpenRouter.