API Best Practices
1. Always validate inputs
budget: float = Field(gt=0, lt=500)
2. Return consistent responses
{"prediction": ..., "confidence": ...}
3. Add health checks
@app.get("/health")
4. Handle errors gracefully
except Exception as e:
raise HTTPException(500, detail=str(e))
5. Document your API (FastAPI does this automatically!)