ai-query is intentionally layered. You should not learn everything at once.
Start Here
If you are new, follow this order:The Decision Tree
I just want to call a model
Usegenerate_text().
I want streamed model output
Usestream_text().
I want the model to call Python functions
Use tools.I want memory or sessions
UseAgent.
I want metadata about an agent response
UseAgent.run().
I am building a CLI or web UI
UseAgent.turn().
I want to serve many users
UseAgentServer.
Import Map
Common imports:Product Boundaries
These are the boundaries to keep in your head:- Providers create models.
- Core functions run model calls.
- Tools give models capabilities.
- Agents add identity, state, storage, and message history.
- Turns expose one live agent execution.
- Servers expose agents over HTTP, SSE, WebSocket, and RPC.