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

# Google ADK

> Capture every model call, tool call, and agent step from a Google ADK app with one line.

If your app uses **Google ADK**, Bento captures every model call, tool call, and agent run for you. No per-call code.

```python theme={null}
import bentolabs_sdk as bento

bento.init(
    user_id=lambda: get_current_user_id(),
    session_id=lambda: get_current_session_id(),
)
bento.instrument()
```

That's the whole integration. Run your app and the dashboard fills in immediately.

<Note>
  Not on ADK? For raw LLM SDKs (OpenAI, Anthropic, Bedrock, Vertex), use [`bento.track_ai`](/python/track-ai). For a framework that already emits OpenTelemetry (LangChain, LlamaIndex, Pydantic AI, or a TypeScript framework like the Vercel AI SDK or Mastra), see [Export from any framework](/otel-export). All of these mix freely in the same app.
</Note>

## Install

```bash theme={null}
pip install "bentolabs-sdk[adk]"
```

The `[adk]` extra pulls in the [OpenInference](https://github.com/Arize-ai/openinference) tracer for ADK. The base wheel stays small.

## `bento.instrument()`

Call this once at app startup, after `bento.init(...)` and before any LLM call.

```python theme={null}
bento.instrument()           # auto-detects ADK
bento.instrument("adk")      # explicit
```

With no argument, Bento activates ADK if it's installed and returns `"adk"`, or returns `None` when the `[adk]` extra is missing. Passing `"adk"` activates ADK by name. An unknown name raises `ValueError`; a missing `[adk]` extra logs a warning and returns `None`. The call is safe to repeat: a second call with the same target is a no-op, and a second call with a different target logs a warning and is ignored.

`bento.shutdown()` removes every active integration on the way out.

## Identity at init

To stamp every captured span with `user_id`, `session_id`, and `tags` without threading them through your code, pass getters to `bento.init(...)`:

```python theme={null}
bento.init(
    user_id=lambda: get_current_user_id(),
    session_id=lambda: get_current_session_id(),
    tags=lambda: ["env:prod"],
)
```

A getter is any zero-argument callable. Bento calls it on every span and writes the result. Three common patterns:

```python theme={null}
# FastAPI / Starlette
bento.init(user_id=lambda: Request.scope["state"].user_id)

# Your own ContextVar
from contextvars import ContextVar
current_user: ContextVar[str | None] = ContextVar("current_user", default=None)
bento.init(user_id=current_user.get)

# Flask / Django
bento.init(user_id=lambda: g.user.id if g.user.is_authenticated else None)
```

If a getter raises, Bento drops the field for that span and your app keeps running. Telemetry never breaks the host.

For more, see [Configuration → Identity getters](/python/configuration#identity-getters).

## Add custom events

For ad-hoc events alongside the integration, wrap each one with [`bento.track_ai`](/python/track-ai): a custom event before or after a model call, or an event for a step ADK doesn't emit. The integration's spans and your manual ones land in the same dashboard.

If you need a single trace to span multiple LLM and tool calls within one turn, see [Trajectories](/python/trajectories) (advanced).

## Reference

| Function                    | Effect                                                      |
| --------------------------- | ----------------------------------------------------------- |
| `bento.instrument()`        | Auto-detect and activate ADK. Returns `"adk"` or `None`.    |
| `bento.instrument("adk")`   | Activate by name. Raises `ValueError` on unknown names.     |
| `bento.uninstrument()`      | Remove every active integration. Returns the names removed. |
| `bento.uninstrument("adk")` | Remove ADK specifically.                                    |

## See also

<CardGroup cols={2}>
  <Card title="Manual tracking" icon="paper-plane" href="/python/track-ai">
    `bento.track_ai` for SDKs without an integration.
  </Card>

  <Card title="Configuration" icon="gear" href="/python/configuration">
    `init()`, identity getters, env vars, lifecycle.
  </Card>

  <Card title="Trajectories" icon="diagram-project" href="/python/trajectories">
    Group multi-step work into one trace.
  </Card>

  <Card title="OTel transport" icon="cube" href="/python/otel-transport">
    Wire Bento into an existing OpenTelemetry pipeline.
  </Card>
</CardGroup>
