Secure the API endpoint
You have a sentiment analysis model API that needs to be protected with API key authentication.
You've already set up the verify_api_key
function, and now you need to create a protected endpoint that accepts the request with text input and returns predictions from the model. This endpoint should only be accessible to users with valid API keys.
You will be working within main.py
to complete this exercise.
All the supporting code including verify_api_key
and model loading is in model.py
This exercise is part of the course
Deploying AI into Production with FastAPI
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
