Skip to main content
Your agent now exposes a small API surface for session management and running the agent:
  • POST /apps/{app_name}/users/{user_id}/sessions/{session_id} — create a session
  • POST /run — run the agent and receive the full response as JSON
  • POST /run_sse — stream agent events via Server-Sent Events (SSE)
A typical session object looks like:
You can run the same server locally during development and then deploy the identical runtime to Google Cloud so production behavior matches your local testing. Cloud deployment choices
  • Cloud Run — fully managed container platform with automatic scaling. Ideal for single agents and low-ops teams.
  • Google Kubernetes Engine (GKE) — managed Kubernetes when you need more control and have a platform team.
  • Agent Runtime on Agent Platform — a Google-managed runtime built specifically for agents, minimizing ops.
A comparison diagram showing three cloud deployment options—Cloud Run (checked), GKE, and Agent Runtime—each depicted in a cloud with icons and short descriptions (Managed platform, Your cluster, Managed runtime). The graphic includes container/agent illustrations and small metrics like agent counts and operational notes.
When to choose each If you have one agent, ~50 requests/day, and limited ops experience, Cloud Run is typically the best fit. If you operate dozens of agents and have a platform team, consider GKE.

Deploying with ADK to Cloud Run

ADK includes a deploy command for Python agents that builds and deploys a Cloud Run service from your agent directory. Provide the Google Cloud project, region, and service name. Use --trace_to_cloud to enable Cloud Trace so you can inspect production requests end-to-end. Example ADK deployment:
Notes:
  • --service_name sets the Cloud Run service name.
  • --trace_to_cloud wires Cloud Trace into the deployed service for distributed tracing.
  • If you need a private service (recommended for most production deployments), see the private deployment example below.

Building your own container

If you need a custom base image, system dependencies, or plan to deploy to GKE/other platforms, build your own container. The container runs the same ADK API server used locally, ensuring consistent runtime behavior. Minimal Dockerfile example:
Recommendations:
  • Keep image layers small and cache-friendly.
  • Pin key package versions in requirements.txt.
  • If you need system packages, install them before Python dependencies to leverage Docker layer caching.

Example client interactions

After deployment you receive a service URL. Example values used below:
  • app name: support_agent
  • user id: u_42
  • session id: s_1001
  • Cloud Run URL stored in the URL environment variable
Create a session:
Example JSON response (abbreviated):
Run the agent and receive a single JSON response using /run:
Stream events in real time (useful for chat UIs) with Server-Sent Events on /run_sse:
SSE response example (each data: line is an event frame):
JSON is plain-text and language-agnostic, so most platforms can parse these responses.
If your Cloud Run service is private (recommended for many deployments), clients must authenticate using Google Cloud credentials. ADK’s deploy command exposes options to control authentication and other service settings.
To make the Cloud Run service private during deployment, disable unauthenticated access:
When the service is private, clients must use authenticated requests (for example, by attaching an ID token obtained from Google IAM) to call the endpoints.

Tracing production requests

When a user reports a slow request (for example, a 6-second response), you need visibility into that single request. Enabling Cloud Trace with --trace_to_cloud produces distributed traces for each production request. These traces show a timeline of operations (invocations, agent runs, LLM calls, external tool calls) and their durations.
A "Cloud Trace" dashboard showing horizontal timeline bars across a 0–6s scale. Each row represents an operation (e.g., invocation, agent_run, call_llm, execute_tool lookup_order) with colored bars and duration labels like 6.0s and 5.9s.
With tracing enabled you can:
  • Open the trace for the slow request and see where time was spent (for example, a lookup_order tool call consuming 4 of the 6 seconds).
  • Correlate LLM latency with external API latency.
  • Pinpoint timeouts, retries, and long-running tool calls.
ADK exposes trace settings at deploy-time and in server configuration so you can enable tracing selectively for production services. See Cloud Trace docs for details on viewing and analyzing traces.

Post-deploy considerations

Deployment is the beginning of production operations. Integrate safety, quality, and operations workflows into your pipeline:
  • Run the evaluation suite (evals) before pushing changes to production.
  • Keep confirmation/approval gates for tools that can cause damage.
  • Lock down every connection to external services and follow least-privilege authentication.
  • Monitor performance (Cloud Trace) and usage to detect regressions or cost spikes.
  • Maintain an incident playbook and rollbacks for problematic releases.
A diagram titled "Deployment Isn't the End" showing a user request flowing through Cloud Run, an API server, and agent.py to a lookup_order service. It also shows icons for Connections, a billing.evalset.json file (12 cases), and an Approval step.
Summary
  • Wrap your agent in the ADK API server, build a container (or use adk deploy), and deploy to Cloud Run for a managed, autoscaling deployment.
  • Enable Cloud Trace (--trace_to_cloud) to get per-request visibility in production.
  • Continue enforcing evals, approvals, and least-privilege connections as your agent evolves.
Links and references

Watch Video