REST API for ML Model
Exposing a model via an API
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
I want to deploy my [MODEL_TYPE] model from [CONTEXT] as a REST API with FastAPI. The model takes [INPUT_FEATURES] as input and returns [OUTPUT]. Generate the complete API code including: endpoints, data validation with Pydantic, error handling, logging, and Swagger documentation.
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Use Cases
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Ajoutez un décorateur `@app.on_event("startup")` pour charger le modèle en mémoire une fois. Utilisez `Depends` pour l'injecter dans les endpoints : cela évite le rechargement à chaque requête, améliore les performances et simplifie les tests unitaires.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.