Review request

Quiz generator with ChatGPT API, review the cost controls

Solved · 214 viewsasked by dana_ships

Repo or live app

git.example.com/danawhitfield/quiz-gen ↗

Unsure about: CostsSecurity

Teachers generate quizzes; each generation calls the API. I capped it at 20 per day per user. Is that enough to stop a surprise bill?

Comment

2 answers

Marked as helpful by the asker
jonas_k

The per-user cap is good. Two gaps: the cap is enforced in the browser only (move it to the server route, keyed by user id), and there's no global cap. Add a monthly ceiling in the provider dashboard and a hard stop in your route when the month's counter hits it. Then the worst case is a known number.

Comment
nadia_r

Your cap counts requests, not cost. A teacher who pastes a 40-page chapter into the prompt costs you fifty times what a one-paragraph prompt does, and it still counts as one of 20.

Two cheap limits in the route: reject input over a sensible length (a few thousand characters is plenty for a quiz), and set a max output tokens limit on the call so a runaway generation can't write a novel. Then 20 per day is actually a bounded number.

And log input and output token counts per call. After a week you'll know your real cost per quiz instead of guessing.

Comment
Someone pasted a whole textbook chapter last week. I saw it in the bill and didn't understand it. Added a 6,000 character limit. dana_ships
Show the limit in the UI too. A counter under the textarea saves the teacher a confusing error. nadia_r