Bridge by Wekoya / Guides / How to stop one user from running up your AI bill
How to stop one user from running up your AI bill
In short: Give every user of your app their own budget and every key its own limit. On Bridge by Wekoya you send the X-Bridge-End-User header with each request, and Bridge meters that user and stops them at their budget with a 402, while everyone else carries on.
Updated
Three limits, from widest to narrowest
- A naira limit on each API key, checked before every request.
- A budget for each of your users: name the user on each request with
X-Bridge-End-User, and Bridge tracks and limits them separately. See your users' budgets. - Short-lived guest keys for browsers and phones, made by your server, that expire and stop at
max_spend. See browser and mobile apps.
Name the user on each request
reply = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": question}],
extra_headers={"X-Bridge-End-User": user.id},
)Create each user first, or turn on auto-create in the console. When a user's budget is spent, their requests get a 402 end_user_budget_exhausted; show them a friendly message instead of an error.
Common questions
What happens when a user runs out of budget?
Their requests are refused with 402 end_user_budget_exhausted, and nothing is charged for the refused request. Other users are not affected.
Can I call Bridge straight from a mobile app?
Not with your API key, which must stay on your server. Your server makes a short-lived guest key for the signed-in user, limited in spend and uses, and the app uses that.