LangWatch AI Gateway budgets and keys notifications on your phone.

Get a push notification when a LangWatch AI Gateway budget nears or hits its limit, or a virtual key is disabled, revoked or rotated.

gateway.budget.breachedAIMonitoring
How it works

Three steps to your first push

STEP 01

Install the recipe

One click in Studio gives you a personal webhook URL.

STEP 02

Paste your URL into LangWatch

Add it as a webhook for Gateway events.

STEP 03

Get a push on your phone

With the text, sound and buttons from the recipe.

Setup

How to set up the LangWatch gateway events webhook

  1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
  2. Follow the setup notes below for AI Gateway budgets and keys.
  3. Paste your webhook URL as the webhook URL and save.https://••••••••/•••••••• your personal URL, shown after install
  4. Send a test fire to check it.
  5. In LangWatch, go to **AI Gateway → Webhooks** and add an endpoint with the URL above. Subscribe it to the `gateway.budget.*` and `gateway.virtual_key.*` events. The recipe ignores `gateway.request.*`, which would push on every call.
  6. **Availability:** gateway webhooks are an **Enterprise** feature.
  7. LangWatch batches deliveries; when a batch holds several events, the push describes the most important one and says how many more there are. The **Send test** button gives a quiet "LangWatch connected" push.
  8. LangWatch can sign requests with `X-LangWatch-Signature` (HMAC-SHA256), but JustPush doesn't check it yet, so keep your endpoint URL private.
The code

What runs when the webhook arrives

Studio calls handleRequest(request) with the incoming webhook and sends the message it returns. It's yours after install; change anything.

transform.js
1// LangWatch → AI Gateway webhooks (budgets and virtual keys)
2// Fires for LangWatch AI Gateway events: budget thresholds and breaches, and virtual
3// key changes. Request-level events are skipped because they'd push on every call.
4// Docs: https://langwatch.ai/docs/features/webhooks
5
6const EVENTS = {
7 "gateway.budget.threshold_crossed": { title: "⚠️ Budget almost used", priority: 0 },
8 "gateway.budget.breached": { title: "🚫 Budget exceeded", priority: 1 },
9 "gateway.virtual_key.created": { title: "🔑 Virtual key created", priority: -1 },
10 "gateway.virtual_key.rotated": { title: "🔄 Virtual key rotated", priority: -1 },
11 "gateway.virtual_key.disabled": { title: "⏸️ Virtual key disabled", priority: 0 },
12 "gateway.virtual_key.enabled": { title: "▶️ Virtual key enabled", priority: -1 },
13 "gateway.virtual_key.revoked": { title: "⛔ Virtual key revoked", priority: 0 },
14}
15
16// Look a key up in one of the tables above, ignoring inherited names like "toString".
17function pick(table, key, fallback) {
18 return Object.prototype.hasOwnProperty.call(table, key) ? table[key] : fallback
19}
20
21function usd(value) {
22 const n = Number(value)
23 return value != null && Number.isFinite(n) ? `$${n.toFixed(2)}` : null
24}
25
26function handleRequest(request) {
27 const body = request.body || {}
28 const batch = Array.isArray(body.batch) ? body.batch : [body]
29
30 // "Send test" delivers a test.ping; confirm the connection quietly.
31 if (batch.some((envelope) => envelope?.type === "test.ping")) {
32 return { title: "🔔 LangWatch connected", message: "Test event received", topic: "LangWatch", priority: -1 }
33 }
34
35 // Deliveries are batched; push about the most important event in the batch.
36 const events = batch.filter((envelope) => pick(EVENTS, envelope?.type, null))
37
38 if (!events.length) {
39 console.log("No budget or virtual key events in this delivery — skipping")
40 return null
41 }
42
43 events.sort((a, b) => EVENTS[b.type].priority - EVENTS[a.type].priority)
44 const envelope = events[0]
45 const event = EVENTS[envelope.type]
46 const data = envelope.data ?? {}
47 const more = events.length > 1 ? ` (+${events.length - 1} more)` : ""
48
49 if (envelope.type.startsWith("gateway.budget.")) {
50 const spent = usd(data.spent_usd)
51 const limit = usd(data.limit_usd)
52 const blocking = envelope.type === "gateway.budget.breached" && data.on_breach === "block"
53 const scope = [data.scope_type?.replace(/_/g, " "), data.window ? `per ${data.window}` : null].filter(Boolean).join(", ")
54
55 return {
56 title: event.title + more,
57 message:
58 (spent && limit ? `${spent} of ${limit}` : "Budget limit reached") +
59 (scope ? ` (${scope})` : "") +
60 (blocking ? " — requests are being blocked" : ""),
61 topic: "LangWatch",
62 // A blocking budget means production traffic is failing right now.
63 priority: blocking ? 2 : event.priority,
64 }
65 }
66
67 const key = data.name ?? data.virtual_key_id ?? data.id
68
69 return {
70 title: event.title + more,
71 message: key ? `Key ${key}` : "A virtual key changed",
72 topic: "LangWatch",
73 priority: event.priority,
74 }
75}
Payload

The LangWatch gateway.budget.breached webhook

This is what LangWatch sends to your URL for gateway events. It is a sample, trimmed to the fields recipes use.

gateway.budget.breached · sample.json
1{
2 "batch": [
3 {
4 "id": "01K1ZX3:breached",
5 "data": {
6 "window": "month",
7 "event_id": "bgt_01H:vk_01H:breached:1790553600000",
8 "budget_id": "bgt_01H",
9 "limit_usd": "25",
10 "on_breach": "block",
11 "spent_usd": "25.1042",
12 "event_type": "gateway.budget.breached",
13 "scope_type": "virtual_key",
14 "end_user_id": null,
15 "occurred_at": "2026-09-29T14:03:11.482Z",
16 "virtual_key_id": "vk_01H",
17 "bucket_scope_id": "vk_01H",
18 "organization_id": "org_01H",
19 "anchor_project_id": null,
20 "period_started_at": "2026-09-01T00:00:00.000Z"
21 },
22 "type": "gateway.budget.breached",
23 "created": "2026-09-29T14:03:11.482Z",
24 "schema_version": "1"
25 }
26 ]
27}
FAQ

LangWatch AI Gateway budgets and keys notifications: questions

Does this work on iPhone and Android?

Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.

Do I need to write code?

No. Install the recipe in Studio, paste your webhook URL into LangWatch and you are done. The code is there if you want to change the text, the sound or the buttons.

Can I change what the notification says?

Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.

What does it cost?

JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.

Ready when you are

LangWatch on your phone in two minutes.

Install the recipe, paste one URL, done. Free for 30 days, no credit card required.