/ai/v1 and speaks the Chat Completions API verbatim. Your customers swap one base_url; everything else — metering, markup, rate limits, tax, and disputes — is handled for you.
Reselling inference is not the same as metering your own AI app. In that guide, you call the model and report tokens after the fact. Here, Macropay sits on the wire — so budgets, allowlists, and usage events happen at the edge with zero metering code in your service.
Why route through the proxy
One URL, every provider
Customers learn one API. You fan out to
gpt-*, claude-*, Gemini, or anything on OpenRouter — and swap providers behind the scenes without touching their code.Markup you keep
Set a customer-facing price per million tokens. Your cost is the upstream rate; the spread is yours. Your provider key never leaves Macropay.
Hard budgets at the edge
Cap a key at “$50/month” and the proxy returns a clean
403 the instant spend plus reserved cost hits the ceiling — no surprise overages.Billed as MoR
Token charges roll into a subscription invoice. Macropay is the seller of record, remits sales tax and VAT worldwide, and absorbs disputes.
Set it up
1
Define the models you'll resell
In the dashboard, open Settings → AI Models and add each model. Per model:
- Display name — what customers pass in
model(e.g.nimbus-fast) - Upstream provider + model — e.g.
openai/gpt-4o-mini - Input cost / 1M tokens — your customer-facing input price
- Output cost / 1M tokens — your customer-facing output price
2
Connect your upstream keys
On the same page, paste your OpenAI / Anthropic / Google / OpenRouter keys. They’re encrypted at rest and only ever sent to the matching provider URL.
3
Mint a proxy key per customer
Create a Proxy API Key under Settings → API Keys → New proxy key. Optional guardrails:
- Allowed models — scope the key to a slice of your catalog.
- Rate limit (RPM) — requests-per-minute cap.
- Budget limit (cents) — hard per-period ceiling; the proxy returns
403 Budget limit exceededonce spent plus reserved hits it. - Customer link — attach a Macropay customer so usage rolls up to their invoice.
4
Hand the key over
The customer sets the key and points
base_url at Macropay. That’s the entire integration on their end.The endpoint
https://api.openai.com/v1/chat/completions. The model field picks which of your configured models to route to — and which provider it lands on.
Streaming
Passstream: true and Macropay returns Server-Sent Events in OpenAI delta format — no matter which upstream provider answers. The official SDKs consume it natively.
Provider coverage
Every response and stream is normalized into the OpenAI Chat Completions shape, so customers write one client and you keep full freedom over routing.Real-time usage headers
Successful responses carry per-request usage and budget headers, so a customer dashboard can show live spend without a second API call.From tokens to invoice
Every call writes a usage event tagged to the customer (when the proxy key is customer-linked). Those tokens roll up exactly like any usage-based meter, so the same invoicing, dunning, and reverse-invoice tooling applies. Pick the billing shape that fits your product:- Mark up tokens
- Sell credit packs
Bill
output_cost_per_million × tokens per request, accumulated and invoiced monthly. Best for postpaid customers on a subscription — they pay for what they used, you keep the spread.Guardrails
The proxy enforces limits before a request ever reaches an upstream provider:FAQ
Can customers ever see my upstream API key?
Can customers ever see my upstream API key?
No. Your OpenAI / Anthropic / Google keys are encrypted at rest and only ever sent to the matching provider URL by Macropay. Customers only hold their own proxy key.
Can I rotate an upstream key without breaking customers?
Can I rotate an upstream key without breaking customers?
Yes. Update it under Settings → AI Models and the next request picks it up. Customer proxy keys are untouched.
What happens when a provider goes down?
What happens when a provider goes down?
The proxy returns
502 upstream_error with the upstream status embedded, so standard SDK retry logic handles transient failures.How does this interact with Macropay fees?
How does this interact with Macropay fees?
The inference markup you charge flows through Macropay like any other transaction and is subject to standard Merchant-of-Record fees. See fees for the breakdown.