Document how to integrate ADK into FastAPI
- Dominant language
- Shell
- Stars
- 1.5k
- Forks
- 1.3k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 34
Description
The docs primarily show how to use ADK's own built-in server tools (`adk web`, `adk api_server`) or deploy using helpers (`adk deploy cloud_run`). While convenient, many developers will want to embed ADK capabilities within their larger, existing web applications (or even green field apps).
I suggest providing a new docs page with a self-contained main.py file demonstrating a simple FastAPI app with one agent , using InMemorySessionService, and exposing one endpoint (non-streaming REST) clearly showing the lifespan setup and request handling.
- Initialization (Lifespan Management): Explain where to initialize ADK components. Lifespan context manager, show how to create singleton instances of SessionService, ArtifactService, MemoryService (if used), and the root Agent within the lifespan context.
- Show how to create the Runner instance, passing the agent and services.
- Implement a simple REST endpoint (POST /run-agent) with a non-streaming example. (Add streaming with SSE and WebSockets later)
Once we have this minimal example, we can further build it out:
- Mapping web requests to ADK sessions: Explain the need to map the web application's concept of a user/session to ADK's user_id and session_id.
- Persistent State: Explain how to switch from InMemorySessionService to DatabaseSessionService
- Implementing streaming with SSE, and WebSockets.
Contributor guide
Assessment
This issue has not been assessed yet.