What’s in It for You
- Clear usage insights — See how each app, project, or customer uses your API
- Cost allocation — No more guesswork when dividing bills
- Budget controls — Set spending limits per tag and get alerts
- Data-driven decisions — Spot trends and optimize your spend
How It Works
AnyAPI uses tags and metadata to attribute API requests. Pass them in themetadata field of your request body, and every request gets tracked and grouped accordingly.
Tagging Your Requests
Using Tags
Tags are labels you attach to requests to track spending by category. Pass them as an array in themetadata field:
Using Custom Metadata
For richer tracking, passspend_logs_metadata with custom key-value pairs that get logged to spend records:
Python
Tracking End Users
Use theuser parameter to track spend per end user:
Python
Using Headers
You can also pass tags and metadata via HTTP headers:Python
Tag Budgets
Set spending limits per tag to control costs. When a tag exceeds its budget, requests with that tag are blocked.Create a Tag Budget
| Parameter | Type | Description |
|---|---|---|
name | string | Unique tag identifier |
max_budget | number | Spending limit in USD |
budget_duration | string | Reset frequency: "1d", "7d", "30d", etc. |
Check Tag Info
Update a Tag Budget
Delete a Tag
Tagging Strategies
By Application
Python
By Environment
Python
Multi-Tenant SaaS
Python
By Team and Project
Python
Best Practices
Smart Tag Names
- Be descriptive: Use
app:customer-chat-prodnotapp1 - Stay consistent: Pick a naming convention and stick to it (e.g.,
key:valueformat) - Include environment: Separate
env:prod,env:staging,env:dev
Cost Management
- Set tag budgets: Start conservative, adjust as needed
- Use budget durations: Monthly (
30d) resets for predictable billing - Tag everything: Untagged requests are harder to attribute later
Security
- Hash user IDs: Protect customer privacy when using the
userparameter - No secrets in metadata: Attribution data is logged in spend records
Start with a simple tag on your next request, then gradually add more as your needs grow. Your future self (and your finance team) will thank you.