Problem
/api/v1/hint and /api/v1/story both default use_bedrock=True and have zero rate limiting. A misbehaving or retry-happy frontend (or a malicious caller, given auth isn't in place yet) can trigger unbounded Bedrock invocations with no cap, risking a surprise AWS bill.
Scope
- Add per-student and/or per-API-key rate limiting on Bedrock-backed endpoints (e.g. token bucket, N calls per minute).
- Add a global daily/monthly Bedrock call budget with a hard cutover to template-only fallback once exceeded (log when this happens).
- Expose current usage via an admin endpoint (e.g.
GET /api/v1/admin/bedrock-usage).
- Make limits configurable via environment variables, with sane documented defaults.
Acceptance criteria
Problem
/api/v1/hintand/api/v1/storyboth defaultuse_bedrock=Trueand have zero rate limiting. A misbehaving or retry-happy frontend (or a malicious caller, given auth isn't in place yet) can trigger unbounded Bedrock invocations with no cap, risking a surprise AWS bill.Scope
GET /api/v1/admin/bedrock-usage).Acceptance criteria
429(or falls back to template mode, your call — document the choice).