Building an ADK agent using QWEN 3 on Vertex AI

Source notebook

Repo path: open-models/agents/qwen3_adk_vertexai.ipynb · Open on GitHub · advanced

Builds and deploys an ADK weather agent using Qwen3 on Vertex AI and Agent Engine.

Summary

This notebook teaches how to deploy Qwen3 from Vertex AI Model Garden to a Vertex AI endpoint, verify it with LiteLLM, and use it as the model behind an ADK tool-calling agent. It defines a simple weather tool, wraps it with ADK FunctionTool, tests the agent locally with an in-memory session, then packages it with AdkApp and deploys it to Vertex AI Agent Engine.

Key code patterns

Vertex AI setup

vertexai.init(project=PROJECT_ID, location=LOCATION, staging_bucket=BUCKET_URI)
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "1"

Initializes Vertex AI with a staging bucket and configures ADK/GenAI calls to use Vertex AI.

Deploy Qwen3 from Model Garden

model = model_garden.OpenModel("publishers/qwen/models/qwen3@qwen3-1.7b")
serving_container_spec = model.list_deploy_options()[0].container_spec
endpoint = model.deploy(
    serving_container_spec=serving_container_spec,
    machine_type="g2-standard-12",
    accelerator_type="NVIDIA_L4",
    accelerator_count=1,
)

Creates a managed Vertex AI endpoint for the open Qwen3 model.

LiteLLM endpoint smoke test

response = completion(
    model=f"vertex_ai/openai/{endpoint.name}",
    messages=[{"content": "Hello, how are you?/no_think", "role": "user"}],
    tools=[convert_to_openai_tool(get_weather)],
    extra_body={"chat_template_kwargs": {"enable_thinking": True}},
)

Verifies the deployed endpoint works through LiteLLM before wiring it into ADK.

ADK tool-calling agent

root_agent = Agent(
    model=LiteLlm(model=f"vertex_ai/openai/{endpoint.name}"),
    name="weather_agent",
    instruction="You are a helpful weather assistant.../no_think",
    tools=[FunctionTool(func=get_weather)],
)

Connects ADK to the custom Vertex AI endpoint through LiteLlm and exposes a Python function as a tool.

Deploy to Agent Engine

app = reasoning_engines.AdkApp(agent=root_agent, enable_tracing=True)
remote_app = agent_engines.create(
    agent_engine=app,
    requirements=[
        "google-cloud-aiplatform[adk,agent_engines]>=1.101.0",
        "litellm==1.73.6.post1",
    ],
)

Packages the ADK agent for managed deployment on Vertex AI Agent Engine.

Models & APIs used

  • Models: publishers/qwen/models/qwen3@qwen3-1.7b
  • APIs / services: Vertex AI, Vertex AI Model Garden, Vertex AI Agent Engine, Cloud Storage
  • SDKs / libraries: google-cloud-aiplatform, google-adk, litellm, vertexai, google-genai, nest-asyncio

When to use this

Use this pattern when you need an ADK tool-calling agent backed by an open model deployed on Vertex AI.

Gotchas & caveats

  • Requires an existing Google Cloud project with the Vertex AI API enabled.
  • BUCKET_URI must be set to a valid Cloud Storage bucket URI for Vertex AI staging.
  • Colab requires explicit user authentication with google.colab.auth.authenticate_user().
  • Qwen3 deployment uses g2-standard-12 with one NVIDIA_L4 accelerator and may incur endpoint charges.
  • Deployment to Agent Engine can take a few minutes.
  • Cleanup flags default to False, so the endpoint and Agent Engine are not deleted unless changed.

Best practices

  • Smoke test the deployed model endpoint with LiteLLM before building the full ADK agent.
  • Use InMemorySessionService and adk.Runner to test agent behavior locally before deployment.
  • Wrap Python functions with FunctionTool so ADK can call them as tools.
  • Use reasoning_engines.AdkApp before deploying the ADK agent to Agent Engine.
  • Delete the Vertex AI Endpoint and Agent Engine after use to avoid ongoing charges.