LLMs Best Practices
Rules for building reliable, safe, and cost-effective LLM applications. Walk this list during design review and before production launch.
Search across all documentation pages
Rules for building reliable, safe, and cost-effective LLM applications. Walk this list during design review and before production launch.
eval() or exec() LLM-generated code without sandboxing.AsyncOpenAI in FastAPI; never block the event loop.finish_reason and response type.response.usage per feature for cost attribution.finish_reason and empty content.Stack versions: This page was written for Python 3.14.0 (stable 3.14, maintenance 3.13), FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 16, 2026