AI Features
AI Budget Management
Every AI request your app makes has a cost. AI Budget Management gives you the tools to track spending, set limits, and make sure you never get surprised by an unexpected bill. Whether you're using Webase's AI or your own API keys, budget controls help you stay in charge.
Prevention is easier than cure. Setting a budget limit before your app goes live is one of the most important things you can do. A single misconfigured feature could generate hundreds of AI requests — a budget limit stops spending before it gets out of hand.
How AI Budgets Work
Each app has its own AI budget that tracks all AI-related spending. Every time your app makes an AI request — whether it's a text completion, a chat message, or an AI service run — the cost is calculated based on the model used and the number of tokens processed, then added to the app's running total. Costs are broken down by:
- Input tokens — The text you send to the AI (prompts, context, conversation history).
- Output tokens — The text the AI generates in response.
- Model pricing — Different models have different per-token rates. Larger models cost more but produce better results.
Setting Budget Alerts and Hard Limits
You can configure two types of budget controls for each app:
- Budget alert — A warning threshold. When spending reaches this amount, you receive a notification but the app continues to work.
- Hard limit — A spending ceiling. When spending reaches this amount, all AI requests are blocked until you raise the limit.
Open AI Budget Settings
In the Application Editor, navigate to your app's AI settings. You'll find the budget configuration section with fields for both alert and hard limit amounts.
Set Your Limits
Enter a dollar amount for your budget alert (e.g., $5.00) and your hard limit (e.g., $10.00). The alert should be lower than the hard limit so you have time to react before requests are blocked.
Save Your Settings
Click save. Your budget limits take effect immediately for all future AI requests from your app.
What Happens When Budget Is Exceeded
When your app's AI spending reaches the hard limit, all subsequent AI requests return a 402 Payment Required error. Your app should handle this gracefully — for example, by showing a message like "AI features are temporarily unavailable" instead of crashing.
To resume AI functionality, you can either:
- Raise the limit — Increase the hard limit in your AI budget settings.
- Wait for reset — Budgets reset at the start of each billing period.
- Optimize usage — Switch to a cheaper model or reduce the frequency of AI calls.
Monitoring AI Spending
You can track your app's AI spending in several places:
- Editor toolbar — Shows real-time token usage and cost for the current session.
- App dashboard — Displays cumulative spending, request counts, and a breakdown by time period.
- Budget alerts — Notifications when spending reaches your alert threshold.
Cost Breakdown by Model
Different models have significantly different costs. Here's a general comparison:
- GPT-4o / Claude Sonnet — Premium models. Best quality, highest cost. Use for complex reasoning, nuanced content, or important customer-facing features.
- GPT-4o Mini / Claude Haiku — Economy models. Good quality at a fraction of the cost. Ideal for high-volume tasks, simple classifications, or internal tools.
Tips for Managing Costs
Smart budgeting keeps AI affordable. These practices can reduce your AI costs by 50-80% without sacrificing user experience.
- Choose the right model for the task — Use smaller, cheaper models for simple tasks (formatting, classification, short answers) and reserve premium models for complex tasks that genuinely need them.
- Set hard limits early — Always set a budget before your app goes live. Even a generous limit protects against unexpected spikes.
- Keep prompts concise — Shorter system prompts and conversation histories mean fewer input tokens and lower costs per request.
- Limit max tokens — Set the max tokens per request to match what you actually need. If your app only needs short answers, don't allow 4000-token responses.
- Monitor regularly — Check your spending dashboard weekly to catch unexpected patterns early.
- Use rate limits — Configure RPM and RPD limits (see AI Configuration) to prevent runaway usage from bugs or abuse.
Next Steps
- AI Configuration (BYOK) — Configure your own API keys and model preferences.
- AI in Your Apps — Learn about the AI features available to your app.
- AI Services — Build structured AI workflows that run within your budget.