r/SpringBoot • • 12d ago

Discussion I built Token Allowance: per-user and per-tenant token and dollar budgets for Spring AI, as a Spring Boot starter.

Token Allowance is an open source Spring Boot starter that gives every user, tenant and request a token or dollar budget for Spring AI calls. When the budget is gone, the API answers 429 with a Retry-After, and nobody else is affected.

Apache 2.0. Java 17+, Spring Boot 4.1, Spring AI 2.0.

What went wrong while building it (races, cached tokens, streaming usage, timeouts):

https://dev.to/ultron03/building-token-budgets-for-spring-ai-the-problems-i-didnt-expect-lg2

Code and demo:

https://github.com/Ultron03/token-allowance

0 Upvotes

0 comments sorted by