AI API & Agent Spend Firewall · 6 providers · Policy Engine · IP Allowlist · Provider Vault · RBAC

AI API & Agent
Spend Firewall.

Hard dollar caps on every LLM call.

When you hit $50, it stops. Not an alert — it stops. Point your existing client at LLMCap and keep the rest of your code.

Per workspace · Per key · Per agent · Per run

The live demo uses sample data — no account, API key, or provider credentials required.

# Before
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

# After — same client, one URL and one header
client = Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    base_url="https://proxy.llmcap.io/anthropic",
    default_headers={"X-LLMCap-Key": os.environ["LLMCAP_KEY"]},
)
# When you hit $50 → 429. No generation starts.

LLMCAP_KEY is your LLMCap proxy key — you create it in the dashboard under Proxy Keys, it starts with tg_live_, and it travels in the X-LLMCap-Key header, never in the URL. ANTHROPIC_API_KEY stays your own provider key: keep it in your environment as you do today. The Provider Secret Vault is the alternative, but it reaches your request only when that request carries no provider credential header, and the official OpenAI and Anthropic Python SDKs both require a credential in normal use — as do the official Google and Cohere SDKs. Mistral is the one official SDK that can omit it. The Provider API Keys page explains where the Vault does apply.

🔒Your API key passes through per-request and is discarded — unless you choose the Vault, where it is encrypted at rest
Only token counts & costs are logged

“I set up a $20 budget alarm for AWS Bedrock. On May 1, I received a bill for several hundred dollars. The alarm was never triggered. AWS support was apologetic but would not offer any kind of refund.”

— andersco onHacker News

Works with every major provider

Anthropic
OpenAI
Google Gemini
Mistral
Cohere
AWS Bedrock

Setup in 5 minutes

How LLMCap works

01

Point your client at LLMCap

Set your client’s base URL to proxy.llmcap.io and send your LLMCap proxy key in the X-LLMCap-Key header. For the Anthropic, OpenAI, Google, Mistral and Cohere SDKs that is two client settings and nothing else. AWS Bedrock is the exception: it is called over plain HTTPS with SigV4 credential headers, so it takes a small request helper rather than an SDK option.

02
$

Set your cap

Define daily, monthly, or per-key dollar limits in the dashboard. Per-model granularity supported.

03
🛡

Sleep peacefully

When a cap is hit, the next call gets a 429 and no model generation is started for it. Calls already in flight still settle, so the cap is a hard stop on new spend.

cost intelligence

Know why costs spike.
Before the bill arrives.

Hard caps are just the start. LLMCap tracks cache efficiency, anomalies, and cost per deployment — so you can fix the root cause.

3.7× spike detected
→ Slack

Spend Anomaly Alerts

When daily spend exceeds 2× your 7-day rolling average, an alert fires in minutes. Not after the invoice.

Slack webhook · configurable multiplier
56%
Yesterday91%
Today56% ↓35pp
cache drop alert

Cache Hit Rate Tracking

Anthropic prompt cache hit rate tracked daily. Alert fires when rate drops > 40 percentage points — a silent token cost spike, caught.

Anthropic only · auto-detected from API response
v2.1.0
$14.20
v2.0.3
$4.80
(untagged)
$1.00
x-llmcap-version: v2.1.0

Deploy Cost Attribution

Tag requests with x-llmcap-version. Dashboard shows cost broken down by deployment — catch expensive prompt refactors before they ship.

All 6 providers · free-form version string
$080% → alert95% → urgent$50
95% of daily cap
→ webhook fired

Budget Threshold Alerts

Proactive warnings at 80% and 95% of your daily cap. You get time to act before LLMCap blocks requests at 100%.

Pure threshold check · fires on every request
31% error rate
>25% threshold

Error Rate Spike Detection

Tracks provider error rates per workspace per hour. When error rate exceeds 25% with at least 20 requests, an alert fires — provider outages caught before your users notice.

Hourly Redis counters · min 20 requests to fire
ai agent spend firewall

Per-agent. Per-run.
Pre-dispatch enforcement.

Tag your LLM calls with agent and run IDs. Set your own daily cap per agent and total cap per run in the dashboard. LLMCap reserves estimated spend before forwarding the request — over-budget calls are refused before the model is invoked.

🔒
1

Reserve

Workspace, agent daily, and run total budgets checked atomically in Redis. Estimated spend reserved before any provider call.

2

Call

Request forwarded to the LLM provider. Reservation holds spend while the call is in-flight — streaming responses pass through in real time.

3

Settle

Actual token cost settled. Unused reservation released. Retry-safe — duplicate request IDs are detected without double-counting spend.

agent integration — one extra dict
client = Anthropic(
    api_key=os.environ["ANTHROPIC_API_KEY"],
    base_url="https://proxy.llmcap.io/anthropic",
    default_headers={
        "X-LLMCap-Key":        os.environ["LLMCAP_KEY"],
        "X-LLMCap-Agent-Id":   "research-agent",
        "X-LLMCap-Run-Id":     "run_8f21a3",
        "X-LLMCap-Request-Id": generate_uuid(),
    },
)

# research-agent hits $5.00/day → 429. Agent pauses.
# run_8f21a3 hits $1.00 total  → 429. This run stops.
# Request-Id makes retries idempotent — no double-count.
Agent spend controls
Per-agent daily cap$3.42 / $5.00 (example)
Per-run total capblocked at $1.00 (example)

Example amounts · Limits set by you · disabled by default

Customer-defined limits

You set agent and run caps in the dashboard. Off by default — opt in per workspace.

Composes with workspace caps

Agent caps enforce alongside existing workspace and key budgets. The tightest limit wins.

Retry-safe

Pass X-LLMCap-Request-Id to prevent double-counting on retries. Duplicate request IDs are rejected before provider dispatch and are not reserved twice.

Untagged traffic

Requests without agent headers have no agent or run budget applied. Normal workspace, key, and model limits still apply.

enterprise security

Enterprise controls.
Per-key granularity.

Not just spend caps — a complete governance layer. Control which models run, who can call from where, and get notified the moment something looks wrong.

Allowlist mode — anything unlisted is refused
allowgpt-4o-miniworkspace
allowclaude-sonnetproject: web
blockclaude-opusworkspace

Policy Engine

Allow and block rules evaluated on every request. Write only block rules and everything else keeps working. Write one allow rule and the workspace becomes an allowlist — anything unlisted is refused. A block always wins over an allow. Scope any rule to a provider, model, project, or a single key.

Model prefix matching
Provider filtering
Org & project scope
Deny-wins evaluation
Fail-open on policy errors · audit logged
Key: tg_live_prod_abc1 — IP allowlist
10.0.0.0/8internal VPC
203.0.113.42CI runner
8.8.8.8unknown

IP Allowlisting

Restrict each API key to specific IP addresses or CIDR ranges. Requests from outside the allowlist are rejected with 403 before they touch your LLM budget.

CIDR range support
IPv4 & IPv6
Per-key granularity
60s Redis cache
Empty allowlist = unrestricted · fails open on infra error
POST https://hooks.pagerduty.com/...200 OK
{
  "event": "budget_threshold",
  "threshold": "95%",
  "spent_usd": 47.50,
  "limit_usd": 50.00
}

Webhook Notifications

Push anomaly events to any HTTPS endpoint — PagerDuty, Slack, Teams, or your own webhook. Payloads are HMAC-SHA256 signed so you can verify authenticity.

spend_spikebudget_thresholdcache_droperror_rate
HMAC-SHA256 signed · multiple endpoints per workspace
admin_audit_log — last 3 entries
07:14faruk@CREATEproxy_keydev-laptop
07:13faruk@UPDATEbudget$50 → $100
07:11faruk@CREATEpolicyblock claude-opus-*

Admin Audit Log

Every key creation, budget change, policy update, and RBAC assignment is logged with actor, timestamp, and target. Filter by action type, actor, or date range. Prune old entries on schedule.

Actor + timestamp
Action type filter
Date range query
Prune API
Atomic DB transactions · immutable append-only
Provider secrets — AES-256-GCMencrypted at rest
Anthropicsk-ant-•••••••••••••••••
OpenAIsk-proj-•••••••••••••••
GoogleAIza•••••••••••••••••••

Provider Secret Vault

Store your Anthropic, OpenAI, Google, Mistral or Cohere API key in LLMCap encrypted with AES-256-GCM. LLMCap uses the stored key only when a request arrives with no provider credential header, and the official OpenAI and Anthropic Python SDKs both require a credential in normal use — as do the official Google and Cohere SDKs. So the Vault applies to raw HTTP calls, to custom clients, and to the official Mistral SDK, which is the one that can be constructed to send no credential. Bedrock keeps signing with your own SigV4 headers.

AES-256-GCM encryption
Per-workspace isolation
Never logged or returned
5 providers · Bedrock via SigV4
96-bit random nonce · keys never exposed after save
Role-based permissions — workspace members
faruk@adminFull access
dev-1@developerKeys & logs
ops@viewerRead only

Role-Based Access Control

Invite teammates with scoped permissions. Admins manage keys and budgets. Developers access logs and analytics. Viewers can read dashboards but can't create or revoke keys.

AdminDeveloperViewer
Organizations · Projects · per-member role assignment

Organizations & Projects

Group workspaces under Organizations — perfect for agencies managing multiple clients. Tag API calls with Projects to get cost attribution broken down by team, product, or feature.

Multi-tenant orgs
Project tagging
Per-org billing
Cross-project reports

Data Privacy

You own your data.
We only touch what's necessary.

LLMCap needs metadata to enforce your cap. It never needs your conversations. Here's exactly what we log — and what we never touch.

We log (metadata only)
provider
model
input_tokens
output_tokens
cost_usd
status
latency_ms
app_version
We never store
System promptcounted in transit, never stored
User messagesforwarded unmodified, never stored
Assistant responsestoken count only, not text
Provider API keyspass-through unless you use the Vault
PII in promptsno content column exists to hold it
Request bodyinspected for token count, never saved
IP addresschecked against allowlist, not stored
LLMCap proxy keystored as bcrypt hash only
🔒

HTTPS end-to-end

Your app → LLMCap and LLMCap → provider are both HTTPS. There is no plaintext endpoint to connect to.

🏦

AES-256-GCM at rest

Provider keys stored in Secret Vault are encrypted with a 96-bit random nonce per entry, key stored separately.

📋

Immutable audit log

Every admin action is append-only. UPDATE and DELETE are blocked at the DB trigger level — not just policy.

0
Providers supported
0
Budget scopes checked per call
0
Output tokens between cap checks · SSE
0
Prompt/response content columns

Available everywhere you code

Works in your workflow

Marketplace

VS Code Extension

Live spend in your status bar. Click to see today's usage, burn rate, and blocked count — without leaving the editor.

Install Extension
>_
PyPI

Terminal CLI

Check spend, browse logs, manage keys, and set policies from the command line. Works on macOS, Linux, and Windows.

pip install llmcap
View on PyPI
🪟
Desktop

Windows Tray App

System tray icon shows live spend. Right-click for stats and quick actions. Always visible, never intrusive.

pip install "llmcap[tray]"
Get Tray App
LLMCap · AI Agent Spend Firewall · Hard caps · Policy Engine · IP Allowlist · Provider Vault · RBAC · Webhooks · Organizations · Audit Log · Pre-dispatch enforcement · 6 providers incl. AWS Bedrock · 3-day trial · LLMCap · AI Agent Spend Firewall · Hard caps · Policy Engine · IP Allowlist · Provider Vault · RBAC · Webhooks · Organizations · Audit Log · Pre-dispatch enforcement · 6 providers incl. AWS Bedrock · 3-day trial · LLMCap · AI Agent Spend Firewall · Hard caps · Policy Engine · IP Allowlist · Provider Vault · RBAC · Webhooks · Organizations · Audit Log · Pre-dispatch enforcement · 6 providers incl. AWS Bedrock · 3-day trial · LLMCap · AI Agent Spend Firewall · Hard caps · Policy Engine · IP Allowlist · Provider Vault · RBAC · Webhooks · Organizations · Audit Log · Pre-dispatch enforcement · 6 providers incl. AWS Bedrock · 3-day trial · LLMCap · AI Agent Spend Firewall · Hard caps · Policy Engine · IP Allowlist · Provider Vault · RBAC · Webhooks · Organizations · Audit Log · Pre-dispatch enforcement · 6 providers incl. AWS Bedrock · 3-day trial ·

Simple pricing

Pick your plan

3-day trial, no charge until it ends · Cancel anytime

Starter
$19/mo

after 3-day trial

  • 2 Proxy Keys
  • All 6 providers incl. Bedrock
  • Daily & monthly caps
  • Per-agent daily & per-run spend caps
  • Budget threshold alerts (80% / 95%)
  • Cache hit rate monitoring
  • Deploy cost attribution
  • 1 Organization · 1 Project
  • 30-day audit log
  • 1 user
  • Email support
Start 3-Day Trial

Credit card required for trial. Cancel before day 3 and you won't be charged.

Two things worth knowing before you subscribe. LLMCap governs API traffic from applications, scripts and agents you control — anything where you can set the base URL and send a header. A ChatGPT, Claude or Gemini web subscription is not supported: it produces no API traffic, so there is nothing for LLMCap to cap. If that is your only AI spend, this product will not help you. And your provider bills you for model usage directly — an LLMCap subscription pays for the gateway, not for your Anthropic, OpenAI, Google, Mistral, Cohere or AWS consumption.

Questions

That depends on a choice you make, and both answers are worth stating. By default — pass-through mode — your provider key travels in the request header, is used once to reach the provider, and is discarded; nothing about it is written to our database. If you opt into the Provider Secret Vault, you are deliberately asking us to hold it, and we store it as AES-256-GCM ciphertext with a 96-bit random nonce, decrypted only in memory to sign an outbound call. In both modes the key is never written to any log, and your LLMCap proxy key is stored only as a bcrypt hash.
Three different credentials, and mixing them up is the most common setup mistake. Your Proxy Key starts tg_live_, is created in the dashboard, and is sent as the X-LLMCap-Key header on every proxied call — it identifies your workspace and is what budgets are enforced against. Your Provider API Key is the Anthropic, OpenAI, Google, Mistral, Cohere or AWS credential you already own: send it per request, or store it in the Provider Secret Vault. A Management API Key starts gk_live_, is optional and advanced, and is used as Authorization: Bearer to call the LLMCap management API from your own scripts — it never carries model traffic. The older header name x-tokenguard-key still works and is deprecated; new integrations should send X-LLMCap-Key.
Yes — streaming is supported from day one. LLMCap passes SSE chunks through in real time and counts output tokens as they arrive. If the budget is exceeded mid-stream, the connection is closed and a final budget_exceeded event is sent. Cutting the stream stops further spend; the tokens the provider already generated before the cut are counted and charged, because the provider produced them.
The next incoming request is refused with HTTP 429 and no model generation is started for that blocked call. One detail worth stating plainly: on Anthropic, LLMCap prices the request through Anthropic's count_tokens estimation endpoint before running the budget check, so that endpoint is contacted even for a request that then gets refused — it returns a count, not a completion. Every other provider is priced locally, with no provider contact at all. What your provider ultimately bills you for is between you and them; what LLMCap controls is whether the generation call is made, and for a blocked request it is not. Your app receives the same 429 response structure providers use for rate limiting, so existing error handling works as-is. Calls that were already in flight when the cap was reached still finish and settle — see the next question.
Yes, by roughly the cost of the responses already in flight — and it is worth being precise about why. LLMCap checks your budget before forwarding each request, so once the cap is reached nothing new is sent to the provider. But the cost of a response is not known until it exists: a non-streaming call is only settled when it returns, so a single unusually long response can carry you a little past the line, and several calls running at once each pass the check before any of them settles. Streaming responses are re-checked as they arrive — every 100 output tokens on Anthropic, OpenAI, Google, Mistral and Cohere, and roughly every 1,000 on Bedrock, where the stream is measured in bytes — and cut at that point, which is what stops a runaway loop from spending thousands. Treat the cap as a hard stop on new spend, not a to-the-cent ceiling. If you need a tighter bound, declare max_tokens on your calls: LLMCap can then account for the worst case up front instead of assuming a default.
Yes, for five of the six — with one condition worth knowing before you rely on it. The Provider Secret Vault stores your Anthropic, OpenAI, Google, Mistral or Cohere key encrypted at rest with AES-256-GCM (96-bit random nonce per entry). Stored keys are never returned after the initial save and never written to logs. The condition: LLMCap reads the stored key only when a request arrives with no provider credential header, because a header that is present always wins. Your client therefore has to be able to issue a request that carries no provider credential header, and the official OpenAI and Anthropic Python SDKs both require a credential in normal use: OpenAI refuses to construct without one, and Anthropic refuses to send the request. The official Google and Cohere SDKs are the same story for their own reasons — Google refuses to construct without an api_key, Cohere requires a token. Passing a fake key does not help either, because we forward whatever you send. The one official SDK that does reach the Vault is Mistral: construct it with no api_key and it sends no Authorization header at all. So the Vault applies to raw HTTP calls, to custom clients, and to the official Mistral SDK — not to a stock OpenAI, Anthropic, Google or Cohere SDK setup. We checked this by capturing the request each SDK builds, at the versions we tested; official SDK APIs change, and no paid provider call was involved. AWS Bedrock is the exception and cannot be stored at all: SigV4 signing needs an access key and a secret access key, and the vault holds one value per provider, so Bedrock callers send the AWS credential headers with each request instead.
Yes — the Policy Engine takes allow and block rules scoped to a provider, a model, a project, or a single API key. Which rules you write decides how the workspace behaves. Write only block rules and everything else keeps working — that is why putting LLMCap in front of a running application changes nothing. Write your first allow rule and the workspace flips to an allowlist: from then on, anything no allow rule names is refused. A block always wins over an allow, however specific the allow is, so a rule can never be narrowed out of existence. Model names match a version suffix automatically (claude-sonnet covers claude-sonnet-4-6) but never a different model (gpt-4o does not cover gpt-4o-mini). The dashboard states which mode you are in above the rule list.
You configure one or more HTTPS webhook endpoints in the dashboard. When an anomaly is detected (spend spike, budget at 80%/95%, cache drop, or error rate spike), LLMCap POSTs a signed JSON payload to your endpoint within seconds. Each payload includes an HMAC-SHA256 signature in the X-LLMCap-Signature header so you can verify it's genuine. Works with PagerDuty, Slack, Teams, or any custom endpoint.
Yes — AWS Bedrock is fully supported including Claude, Llama, Titan, Mistral, and Cohere models via Bedrock. Pass your AWS credentials in request headers alongside your LLMCap proxy key. LLMCap re-signs requests using SigV4 and forwards them to the Bedrock Runtime. Credentials sent this way are used once and discarded — and headers are the only option for Bedrock, because the Provider Secret Vault holds a single value per provider and SigV4 needs a key pair. This is exactly what fills the gap that AWS Budgets leaves open: AWS Budgets has 8-12 hour reporting lag and sometimes doesn't trigger at all — LLMCap refuses the call before Bedrock is invoked, instead of telling you about it hours later.
Self-hosting is on the roadmap. The proxy is open source (FastAPI + Redis). For now, the managed service at proxy.llmcap.io is the recommended path — it is already deployed and running.
Nothing is stored, but it is worth being exact about what happens in transit. To price a request LLMCap has to parse it: it reads the JSON body to find the model, the stream flag, and the message content it needs to count tokens — and on Anthropic it sends that content to Anthropic's own count_tokens endpoint for an exact figure. What it does not do is keep any of it. The request log records only metadata: provider, model, token counts, cost, status, latency, and app version. There is no column in our database that could hold prompt text, system instructions, user messages, or assistant responses — that is a property of the schema, not a policy we promise to follow. You can confirm exactly what we record by opening the Request Log in your dashboard.
Yes. Your application connects to proxy.llmcap.io over HTTPS — there is no unencrypted endpoint to connect to — and LLMCap's outbound connection to each provider (Anthropic, OpenAI, Google, etc.) is HTTPS as well. We deliberately do not advertise a specific TLS version: the version is negotiated between the client and the platform edge, so promising 1.3 on every connection would be a promise we do not control. Provider API keys you send in request headers are never written to disk or any log. Keys you choose to store in the Provider Secret Vault are encrypted at rest with AES-256-GCM, with a 96-bit random nonce per entry.
LLM calls will fail with a connection error until the proxy recovers. We target 99.5% uptime — the figure in our Terms — via Railway with health monitoring and automatic restarts. It is a target we work to, not a measured track record we can show you yet. For applications requiring higher availability, we recommend wrapping LLMCap calls in a circuit breaker with a configurable direct-to-provider fallback that you can activate if needed. A self-hosted high-availability deployment option is on the roadmap.
No. Requests without X-LLMCap-Agent-Id or X-LLMCap-Run-Id headers have no agent or run budget applied. They are tracked against your workspace and API key budgets as normal. You can run mixed traffic (some tagged, some not) in the same workspace.
They are enforced together — the first exhausted limit blocks the request. If your workspace has a $50/day budget, an agent has a $5/day cap, and a run has a $1.00 total cap, any of the three reaching its limit returns a 429 before the provider is called. Set a high workspace limit for overall protection and tighter agent and run limits for individual workflows — all checked atomically before each request.
When the spending cap is hit during a stream, LLMCap sends a terminal SSE event — data: {"error": "budget_exceeded"} — then closes the connection cleanly. Your existing SSE error handler receives this event the same way it receives any provider-side error, so no special handling is required. On billing: the tokens streamed before the cut were really generated by the provider, so they are counted against your budget and appear in your request log. What the cut prevents is the rest of the response — LLMCap re-checks your budget every 100 output tokens (roughly every 1,000 on Bedrock, where the stream is measured in bytes rather than parsed tokens), so a long runaway generation stops there instead of running to its max_tokens.
Multiple layers limit the blast radius. (1) IP Allowlist — even with valid credentials, requests from IPs outside your allowlist are rejected at the gate before any token is consumed. (2) Provider Secret Vault keys are AES-256-GCM encrypted at rest; an attacker with database access cannot extract them without the separate encryption key. (3) Spending caps are enforced at the proxy — once the cap is reached, new requests are refused, so a stolen key cannot run your bill up past it beyond the calls already in flight. (4) The audit log is append-only and tamper-proof at the database trigger level — every action is recorded and cannot be erased. Assign team members the minimum role they need (RBAC), and enable IP allowlisting on production keys to further reduce exposure.