Skip to main content
Integrate ai-query with FastAPI when you need custom HTTP endpoints, middleware, or want to use your own server infrastructure instead of the built-in serve().

Quick Integration (AgentRouter)

The easiest way to serve an agent is using the AgentRouter. This adds a standard set of endpoints (/chat, /invoke, /state) to your application.

Basic Chat Endpoint (Manual)

If you only need a simple chat endpoint and don’t want the full agent API:

Streaming with SSE

Use StreamingResponse for real-time streaming.

Advanced: Custom Agent Integration

If AgentRouter doesn’t fit your needs, you can integrate the Agent class manually.