Hard limits for AI agents.
Stop runaway AI spending before it happens. MarginGate checks the budget before every model call, stops agents that loop, and shows exactly where each dollar went.
Bring your own provider keys. MarginGate never resells model access: your provider bills you directly.
One setting to change. Nothing else.
MarginGate speaks the same API as the providers. Point your app, framework or automation tool at MarginGate instead of the provider, and every call is checked first.
Agents and workflows
Code using the OpenAI, Anthropic or Gemini SDKs, or a tool such as n8n where you can set the base URL.
Checked before it costs you
- Reserves the worst-case cost against your budget
- Refuses the call if it would go over
- Settles the exact cost when the answer arrives
Your own account
OpenAI, Anthropic, Google Gemini, DeepSeek, xAI or Mistral, billed to you with your own key.
Create a MarginGate key
Sign in with GitHub and set a monthly budget for the key.
Change the base URL
Use https://api.margingate.dev in place of the provider's address.
Add one header
Send your MarginGate key in X-MarginGate-Key. Your provider key stays where it is.
# Python, Anthropic SDK client = anthropic.Anthropic( base_url="https://api.margingate.dev", default_headers={"X-MarginGate-Key": os.environ["MARGINGATE_KEY"]}, )
Limits first. Then see where the money went.
Most tools tell you what you spent after the bill arrives. MarginGate stops the spend before it happens, then helps you spend less.
Hard budgets
Monthly and rolling budgets per key. The worst-case cost is reserved before each call, so a budget can't be overshot by calls in flight.
Loop breaker for agents
Per-run budgets, step limits, a cap on identical repeated steps and on sub-agent depth. A stuck agent is stopped, not billed all night.
Cost per agent and run
Every call is tied to its key, agent and run, with a step-by-step timeline of model calls and tool calls.
Alerts
Signed webhooks when spend crosses your thresholds, spikes suddenly, or a limit stops an agent. Delivered in the background, never slowing your calls.
Exact cost, official prices
Prices come from the providers' official pricing pages, including cached tokens, long-context and off-peak rates.
Ways to spend less
Suggestions from your own usage: a cheaper model where it fits, better caching, right-sized output limits, runaway context growth. Each with an estimated monthly saving.
Pricing
Every plan includes budgets, the loop breaker, cost per agent and run, and alerts. You pay your model provider separately, at their prices, with your own key.
Free
- 5,000 model calls a month
- Budgets, loop breaker and run limits
- Cost per agent and run
- Webhook alerts
Pro
- 100,000 model calls a month
- Everything in Free
- Keep captured prompts for up to 30 days
- Email support
Prices in US dollars. Taxes are added at checkout where they apply. Payments are handled by our reseller, Dodo Payments. Cancel any time; see the refund policy.
Questions
Do you store my provider API key?
No. Your provider key travels with each request, is used for that call only, and is never written to our database or logs.
Do you see my prompts?
Not by default. MarginGate records call metadata: model, token counts, cost, timing and status. Saving prompts and answers is off unless you turn it on for a key; captures are redacted and deleted after the retention period you choose.
What happens when a budget runs out?
The call is refused before it reaches the provider, with a clear error your code can handle. Nothing is billed for a refused call.
Does it work with n8n, Dify or Flowise?
Any tool that lets you change the base URL and add a header can use MarginGate. We have tested n8n's OpenAI and Anthropic credentials; guides for more tools are coming.
Is MarginGate a reseller of AI models?
No. You keep your own accounts with the providers and pay them directly. MarginGate charges only for the control layer.