FastAPI CORS for production agentic APIs
How to configure CORS for a production agentic API without wildcard origins. The allowlist, the credentials flag, and the preflight that breaks SSE.
Loading...
Explore our latest articles and insights about API Development.
20 posts in total
How to configure CORS for a production agentic API without wildcard origins. The allowlist, the credentials flag, and the preflight that breaks SSE.
Why FastAPI lifespan is the only right place for agent startup code. Per-worker initialization, ordered teardown, and the bugs it kills.
How async context managers prevent connection leaks in Python AI services. The lifespan, contextvars, and middleware patterns that survive load.
How to wire LangGraph into a FastAPI chatbot API with streaming, persistence, and per-user threads. The production pattern that scales past demos.
How FastAPI Depends makes agent auth testable and composable. The pattern, the chain, and why module-level globals break at scale.
How to persist agent state in Postgres so conversations survive restarts. The schema, the session writer, and the idempotency rule that prevents loss.
How a service layer in an AI agent codebase decouples business logic from HTTP routes. The pattern, the tests, and the refactor from a fat route.
How to parse environment variables in Python AI services without os.environ.get footguns. Pydantic Settings, type coercion, and the validation layer.
How to sanitize agent API inputs beyond frontend validation. Prompt injection defense, payload limits, and the 4 layers every agent service needs.
How to version an agentic API without breaking clients. The URL prefix pattern, the deprecation playbook, and when to ship v2.
How to use JWTs for agentic API auth. The claims that matter, the refresh rotation pattern, and the middleware that keeps long-running agents logged in.
How to rate limit a FastAPI agent service. Token buckets per user, burst control, and the Redis pattern that survives multi-worker deployments.