Skip to main content
Ship an AI gateway without building the boring half. Point your customers at a single OpenAI-compatible URL, and Macropay sits in the request path to route to OpenAI, Anthropic, Google, or OpenRouter, count the tokens, enforce per-key budgets, and roll the spend onto an invoice — under your pricing, as Merchant of Record. The proxy lives at /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.
This fits AI gateways, agent platforms, and any product where customers consume models on your account and you want to bill them per token without writing a meter.

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
Macropay charges customers your configured rate and pays the upstream rate — the difference is your margin, calculated automatically.
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 exceeded once 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

Fully OpenAI-compatible: send the exact body you’d send to 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

Pass stream: 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:
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.
Because this runs on Macropay’s meter and product engine, you get the agentic-billing primitives for free: track AI cost as COGS per customer, and pair token spend with outcome signals so you can bill — and prove ROI — on results, not just raw usage.

Guardrails

The proxy enforces limits before a request ever reaches an upstream provider:

FAQ

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.
Yes. Update it under Settings → AI Models and the next request picks it up. Customer proxy keys are untouched.
The proxy returns 502 upstream_error with the upstream status embedded, so standard SDK retry logic handles transient failures.
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.