Track and enforce rate limits so your agent doesn't get throttled.
uvicorn ratelimiter.app:app --port 8012
curl -s -X POST http://localhost:8012/v1/limits \
-H "Content-Type: application/json" \
-d '{"key": "openai-api", "max_requests": 60, "window_seconds": 60}' | jq
curl -s http://localhost:8012/v1/check/openai-api | jq '.allowed'
curl -s -X POST http://localhost:8012/v1/consume/openai-api | jq
Returns allowed (true/false), remaining, and retry_after_seconds (how long to wait if exhausted).
curl -s http://localhost:8012/v1/limits | jq
curl -s -X POST http://localhost:8012/v1/reset/openai-api | jq
curl -s -X DELETE http://localhost:8012/v1/limits/openai-api | jq
| Method | Path | Description |
|---|---|---|
| -------- | ------ | ------------- |
| POST | /v1/limits | Create/update a rate limit |
| GET | /v1/limits | List all rate limits |
| GET | /v1/check/{key} | Check if next request is allowed |
| POST | /v1/consume/{key} | Use one request from quota |
| POST | /v1/reset/{key} | Reset quota to full |
| DELETE | /v1/limits/{key} | Delete a rate limit |
共 1 个版本