Get startedGet started for free

Add rate limiting to endpoint

The next step in securing the API endpoint is to add rate limit logic to the previously defined test_api_key function that checks both the API key validity and enforces rate limiting. You need to integrate the rate limiting logic that you defined in the RateLimiter class and raise HTTP exceptions in case the limit is exceeded.

You will be updating the test_api_key function from main.py script here.

All the supporting code for model creation and loading is in model.py

This exercise is part of the course

Deploying AI into Production with FastAPI

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise