Building production-ready AI systems requires a shift from simple prompting to structured orchestration. With the Google Agent Development Kit (ADK) And pythonYou can create robust agents that handle complex reasoning and state management.
In this post, I’ll walk you through the core concepts of the ADK: from defining your first agent to deploying it as a production-ready API using FastAPI.
![image[1]-[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI For Windows 7,8,10,11-Winpcsoft.com](https://winpcsoft.com/wp-content/plugins/wp-fastest-cache-premium/pro/images/blank.gif)
What is an AI agent?
Unlike a standard LLM that simply generates text based on a prompt, an AI agent includes the following Reasoning and decision logic. It can interpret user requests, decide what actions to take, and interact with tools or other components to complete a task.
In practice, an agent can:
- Reason: Interpret the user’s intent and understand the constraints in the request.
- Act: Call external tools, APIs, or functions to retrieve information or perform operations.
- Collaborate: Collaborate with other specialized agents to solve more complex tasks.
This makes agents particularly useful for construction structured, multi-stage AI applications.
Our use case
![image[2]-[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI For Windows 7,8,10,11-Winpcsoft.com](https://winpcsoft.com/wp-content/plugins/wp-fastest-cache-premium/pro/images/blank.gif)
In this example we will create one Travel planning agent that can respond to user queries about travel and destinations. The agent processes the user’s request, generates relevant travel suggestions and helpfully structures the response.
To make the system accessible to other applications, we expose the agent via a REST API built with FastAPIwhich enables integration with web applications, chat interfaces and other services.
Step 0: Setting up your environment
To join in, you’ll need Python 3.10+ and a package manager like pipx or uv (which is significantly faster than standard Pip).
If you don’t have uv yet, you can install it with a simple curl command:
# Install uv
curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
Project structure
For this project we expect the following project structure:
![image[3]-[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI For Windows 7,8,10,11-Winpcsoft.com](https://winpcsoft.com/wp-content/plugins/wp-fastest-cache-premium/pro/images/blank.gif)
Initialize your project
Once uv is installed, from the root of your repository, install the relevant libraries for both the agent and API layers and enable the virtual environment:
# Install the Google ADK, FastAPI, and Uvicorn (the ASGI server)
uv add google-adk fastapi uvicorn
# Sync dependencies and activate your environment
uv sync
source .venv/bin/activate
The next step is to initialize your agent via the ADK CLI, which creates the necessary directory structure for your agent’s logic.
# Create a new agent project
adk create my_travel_planner
The .env configuration
Safe handling of API keys is of utmost importance. You should create an .env file in the my_travel_planner directory (or fill out the existing .env template file created in the step above) to manage credentials.
It is important that you never put this file under version control. Make sure you add this to the .gitignore file (if it doesn’t already exist).
- Option 1 (Google AI Studio): If you use a standard Gemini API key from Google AI Studioset GOOGLE_GENAI_USE_VERTEXAI=False and add your key.
- Option 2 (Vertex AI): If you’re on Google Cloud, set GOOGLE_GENAI_USE_VERTEXAI=True and reference your application credentials. You can follow this link for accurate documentation.
# .env template
GOOGLE_API_KEY=your_gemini_api_key_here
GOOGLE_GENAI_USE_VERTEXAI=False
# Optional for Vertex AI:
# GOOGLE_APPLICATION_CREDENTIALS=path/to/your/credentials.json
Step 1: Define the agent
The “brain” of your system is defined in my_travel_planner/agent.py. Here we give the agent a name, a specific model (like gemini-2.5-flash) and clear instructions about his persona.
from google.adk.agents import Agent
def get_root_agent():
# The Root Agent (The "Brain")
travel_planner = Agent(
name="travel_planner",
model="gemini-2.5-flash",
description="A comprehensive travel planning assistant.",
instruction="""You are a world-class travel planner.
Recommend places to visit based on the user's query.""",
)
return travel_planner
root_agent = get_root_agent()
Step 2: Manage storage with sessions and runners
Stateless LLMs forget the context as soon as the request ends. Agents are required for production systems Mémoire. ADK manages this through meetings and the runner.
- Sessions: Store agent conversation history, user information, and intermediate statuses.
- Runner: Orchestrates the entire interaction – receiving input, relaying it to the brain, and maintaining state.
Here’s how you can run this pipeline asynchronously. In the root of your repository, create run.py like this:
from google.adk.sessions import InMemorySessionService
from google.adk.agents.llm_agent import Agent
from google.adk.runners import Runner
from google.genai import types # For creating message Content/Parts
import asyncio
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path(__file__).parent / "my_travel_planner" / ".env") # Load environment variables from the .env file
from my_travel_planner.agent import get_root_agent
APP_NAME = "travel-planner_app"
USER_ID = "user_1"
SESSION_ID = "session_001"
async def setup_session_and_runner(root_agent: Agent = None, session_id: str = SESSION_ID):
# Setup Runner for execution
session_service = InMemorySessionService()
session = await session_service.create_session(app_name=APP_NAME, user_id=USER_ID, session_id=session_id)
runner = Runner(agent=root_agent, app_name=APP_NAME, session_service=session_service)
return session, runner
async def call_agent_async(query: str, root_agent: Agent = None, session_id: str = SESSION_ID) -> str:
content = types.Content(role='user', parts=[types.Part(text=query)])
session, runner = await setup_session_and_runner(root_agent=root_agent, session_id=session_id)
events = runner.run_async(user_id=USER_ID, session_id=session_id, new_message=content)
final_response_text = "No response received."
async for event in events:
# Key Concept: is_final_response() marks the concluding message for the turn.
if event.is_final_response():
if event.content and event.content.parts:
final_response_text = event.content.parts[0].text
elif event.actions and event.actions.escalate:
final_response_text = f"Agent escalated: {event.error_message or 'No specific message.'}"
break
print(f"<<< Agent Response: {final_response_text}")
return final_response_text
async def run_agent_pipeline(query: str) -> str:
root_agent = get_root_agent()
return await call_agent_async(query=query, root_agent=root_agent, session_id=SESSION_ID)
if __name__ == "__main__":
user_query = ("I'm planning a trip to Paris in the spring. What are some must-see attractions and local events "
"during that time?")
asyncio.run(run_agent_pipeline(query=user_query))
Step 3: Turn your agent into an API
To make your agent useful in the real world, we need to expose it as an API. FastAPI is the modern standard for this because it is powerful, uses type hints for validation, and generates automatic Swagger documentation.
By wrapping our ADK pipeline into a POST endpoint, we can connect our agent to frontends, mobile apps, or other microservices.
In the repository root, we create api.py, where we define a simple /ask endpoint:
from fastapi import FastAPI
from pydantic import BaseModel
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path(__file__).parent / "my_travel_planner" / ".env")
from run import run_agent_pipeline
app = FastAPI(title="Travel Planner AI", description="Powered by Google ADK + Gemini")
class QueryRequest(BaseModel):
query: str
class QueryResponse(BaseModel):
query: str
response: str
@app.post("/ask", response_model=QueryResponse)
async def ask_agent(request: QueryRequest):
response = await run_agent_pipeline(query=request.query)
return QueryResponse(query=request.query, response=response)
Run your server with: uv run uvicorn api:app –reload
The server starts at http://localhost:8000 and interactive documents (Swagger UI): http://localhost:8000/docs
![image[4]-[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI For Windows 7,8,10,11-Winpcsoft.com](https://winpcsoft.com/wp-content/plugins/wp-fastest-cache-premium/pro/images/blank.gif)
Final Thoughts: The Road to Production
A local script is a good start, but production-ready requires a few more steps:
- Check: Write unit tests to verify that agent logic handles edge cases.
- Containerize: Use Docker to ensure that “it works on my computer” is translated into “it works on the server”.
- Insert: Ship your container to a cloud provider such as Google Cloud (Cloud Run) or AWS.
Ready to build? Get the code from the GitHub repo and start building your own specialized agent workflows today!
✨ We thank that Google AI/ML Developer Programs Google Cloud Credits Support Team.
✨ The source code can be accessed on GitHub Here.
✨ If you like the article, please subscribe to my latest.
To get in touch, contact me at LinkedIn or about ashmibanerjee.com.
GenAI Usage Disclosure: GenAI models were used to check the blog for grammatical inconsistencies and refine the text for clarity. The authors take full responsibility for the content presented in this blog.
![]()
[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI was originally published in Google Developer Experts on Medium, where people are continuing the discussion by highlighting and responding to this story.
![[Tutoriel] From Agents to APIs: Building Production-Ready AI Systems with Google ADK & FastAPI For Windows 7,8,10,11-Winpcsoft.com](https://winpcsoft.com/wp-content/uploads/2026/04/1zxvZPIK0woFdfCbfxJyC_w.png)