The sub-account key is a normal sk-aig-* key. It works in every framework that supports the OpenAI SDK — no SDK changes, no special routing on your side.
// On every new customer signup in your app: const r = await fetch("https://api.aigateway.sh/v1/sub-accounts", { method: "POST", headers: { "Authorization": `Bearer ${AIGATEWAY_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ name: `customer_${customerId}`, spend_cap_cents: 5000, // $50/mo hard cap rate_limit_rpm: 300, allowed_models: ["openai/gpt-5.4-mini", "anthropic/claude-haiku-4.5"], default_tag: `tenant:${customerId}`, }), }); const { key, id } = await r.json(); // → key: "sk-aig-..." id: "sa_9f3k..." // Save id; hand key to customer (or proxy through your backend).
# Your customer uses it like any other OpenAI key: from openai import OpenAI client = OpenAI( base_url="https://api.aigateway.sh/v1", api_key="sk-aig-...", # the sub-account key ) r = client.chat.completions.create( model="openai/gpt-5.4-mini", messages=[{"role": "user", "content": "Hi"}], ) # Spend lands on YOUR AIgateway bill, tagged tenant:abc # Hits cap at $50 → returns 402 payment_required # Webhook sub_account.budget.exhausted fires to your backend
Sub-accounts are the billing layer most multi-tenant AI products end up building from scratch on top of a single-provider key. We've already built it.
If your product has customers — and your customers' spend should NOT show up on your founder credit card — sub-accounts are how you do it without writing your own billing layer.
Pair sub-accounts with your identity, billing, and CRM stack. Mint on user creation. Cap based on plan. Surface in your existing dashboards.
Sub-accounts are included in standard PAYG. You pay model cost + 5% on the actual usage, whether it lands on the parent key or a sub-account. No per-seat fee. No per-sub-account fee. No charge if a sub-account never gets used.
* Free credit applies only to selected models. Expires 7 days after signup. See the list.