LLM API Cost
What It Depends On
The paid LLM-API is priced by tokens: the longer the prompt and response, the more expensive the request. Uncontrolled integration into a public service is a direct path to budget depletion.
How to Control
In protecting the paid API there are four layers:
- Cache by URL — a repeated request costs 0 tokens;
- Quota (for example, 3 requests/day) — a limit per user;
- Token limit (
max_tokens) — a ceiling for one response; - Server-side key — the front-end cannot steal it and make a direct call.