> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google ADK

> Connect Google Agent Development Kit to Orq.ai via OpenTelemetry. Trace agent workflows, tool calls, and Gemini model interactions.

<CardGroup cols={1}>
  <Card title="Observability" icon="chart-line" href="#observability">
    Instrument your code with OpenTelemetry to capture traces, logs, and metrics for every LLM call, agent step, and tool use.
  </Card>
</CardGroup>

## Observability

### Getting Started

Google Agent Development Kit (ADK) is a flexible, model-agnostic framework for developing and deploying AI agents. ADK simplifies building complex agent architectures with workflow orchestration, tool integration, and multi-agent collaboration. Integrate with Orq.ai to monitor agent behavior, track tool usage, analyze workflows, and optimize your agent systems.

### Prerequisites

Before you begin, ensure you have:

* An Orq.ai account and [API Key](/docs/ai-studio/organization/api-keys)
* Google API key (for model access)
* Python 3.8+
* Google ADK installed in your project

### Install Dependencies

**Python:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  # Google ADK
  pip install google-adk

  # OpenTelemetry packages
  pip install opentelemetry-sdk opentelemetry-exporter-otlp

  # OpenInference instrumentation for ADK (if available)
  pip install openinference-instrumentation-google-adk
  ```
</CodeGroup>

**Java:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  <!-- For Maven -->
  <dependency>
      <groupId>com.google.ai</groupId>
      <artifactId>google-adk</artifactId>
      <version>latest</version>
  </dependency>
  ```
</CodeGroup>

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  // For Gradle
  implementation 'com.google.ai:google-adk:latest'
  ```
</CodeGroup>

### Configure Orq.ai

Set up your environment variables to connect to Orq.ai's OpenTelemetry collector:

**Unix/Linux/macOS:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.orq.ai/v2/otel"
  export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <ORQ_API_KEY>"
  export OTEL_RESOURCE_ATTRIBUTES="service.name=google-adk-app,service.version=1.0.0"
  export GOOGLE_API_KEY="your-google-api-key"
  ```
</CodeGroup>

**Windows (PowerShell):**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  $env:OTEL_EXPORTER_OTLP_ENDPOINT = "https://api.orq.ai/v2/otel"
  $env:OTEL_EXPORTER_OTLP_HEADERS = "Authorization=Bearer <ORQ_API_KEY>"
  $env:OTEL_RESOURCE_ATTRIBUTES = "service.name=google-adk-app,service.version=1.0.0"
  $env:GOOGLE_API_KEY = "your-google-api-key"
  ```
</CodeGroup>

**Using .env file:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  OTEL_EXPORTER_OTLP_ENDPOINT=https://api.orq.ai/v2/otel
  OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer <ORQ_API_KEY>
  OTEL_RESOURCE_ATTRIBUTES=service.name=google-adk-app,service.version=1.0.0
  GOOGLE_API_KEY=your-google-api-key
  ```
</CodeGroup>

### Integrations

Choose your preferred OpenTelemetry framework for collecting traces:

### OpenInference

**Best for**: Comprehensive ADK instrumentation with automatic tool and model tracking

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from openinference.instrumentation.google_adk import GoogleADKInstrumentor
  from opentelemetry import trace
  from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
  from opentelemetry.sdk.trace import TracerProvider
  from opentelemetry.sdk.trace.export import BatchSpanProcessor

  provider = TracerProvider()
  provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
  trace.set_tracer_provider(provider)

  # Instrument Google ADK
  GoogleADKInstrumentor().instrument()

  # Now use ADK normally - all agent operations will be traced
  import google.adk as adk
  from google.adk.runners import Runner
  from google.adk.sessions import InMemorySessionService
  from google.genai import types
  import asyncio


  def get_weather(location: str) -> str:
      """Return current weather for a location."""
      return f"Sunny in {location}, 22C"


  async def main():
      # Create an agent with a tool
      agent = adk.Agent(
          name="Helper",
          instruction="Use the provided tool to answer questions briefly.",
          model="gemini-2.5-flash",
          tools=[get_weather],
      )

      # Create session and runner
      session_service = InMemorySessionService()
      runner = Runner(
          agent=agent,
          app_name="simple-helper",
          session_service=session_service
      )

      # Create a session (await the async call)
      session = await session_service.create_session(
          app_name="simple-helper",
          user_id="user1"
      )

      # Simple one-shot example
      question = "What's the weather in Paris?"
      content = types.Content(role='user', parts=[types.Part(text=question)])

      # Run the agent (this is also async)
      events = runner.run_async(
          user_id="user1",
          session_id=session.id,
          new_message=content
      )

      # Get the response
      async for event in events:
          if event.is_final_response():
              response = event.content.parts[0].text
              print(f"Q: {question}")
              print(f"A: {response}")

  # Run the async main function
  if __name__ == "__main__":
      try:
          asyncio.run(main())
      finally:
          provider.force_flush()
          provider.shutdown()
  ```
</CodeGroup>

<Info>
  To view more examples of ADK implementation, browse the [Google ADK Samples repository](https://github.com/google/adk-samples)
</Info>

### Next Steps

**Verify your Traces** in the **orq.ai** Studio.

<Frame caption="Traces will be shown for the session and calls made within the ADK implementation.">
  <img src="https://mintcdn.com/orqai/EqUGDI2og-dnTmDI/images/docs/5989db35f83a76af140ae73595632a832d0aa30b98e7294d4298bfe219dbf46f-Screenshot_2025-09-22_at_11.21.09.png?fit=max&auto=format&n=EqUGDI2og-dnTmDI&q=85&s=3cb219d647b3178cf6d8be5730b32840" alt="Traces will be shown for the session and calls made within the ADK implementation." width="1281" height="685" data-path="images/docs/5989db35f83a76af140ae73595632a832d0aa30b98e7294d4298bfe219dbf46f-Screenshot_2025-09-22_at_11.21.09.png" />
</Frame>

<Info>
  To learn more about the capabilities of Traces in orq.ai, see [Traces](/docs/ai-studio/observability/traces)
</Info>

## Evaluations & Experiments

Once your agents are running, use **Evaluatorq** to score outputs across a dataset and **Experiments** to compare configurations side-by-side.

<CardGroup cols={2}>
  <Card title="Run Evaluations with Evaluatorq" icon="flask" href="/docs/ai-studio/optimize/evaluators#evaluatorq">
    Run parallel evaluations across your agents and compare results.
  </Card>

  <Card title="Run Experiments via the API" icon="flask-vial" href="/docs/experiments/api">
    Compare agent configurations and view results in the AI Studio.
  </Card>
</CardGroup>
