---
title: "LiteLLM Python SDK"
url: "/docs/proxy/lens/integrations/litellm-python-sdk"
canonical_url: "https://docs.litellm.ai/docs/proxy/lens/integrations/litellm-python-sdk"
type: "docs"
last_updated: "2026-11-28"
summary: "Send LiteLLM Python SDK calls to Lens and group a multi-step pipeline into one named agent run."
related:
  - "/docs/proxy/lens/framework-examples"
  - "/docs/proxy/lens/integrations/deepagents"
---
# LiteLLM Python SDK

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt


Available in LiteLLM v1.113.0 and later.

Install LiteLLM and the OpenTelemetry packages:

```sh
python -m pip install -U litellm opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
```

Set the destination and its key. The callback sends OTLP over HTTP to `/v1/traces` with Bearer authentication in both setups.

| Destination | `LENS_URL` | `LENS_TRACING_KEY` |
| --- | --- | --- |
| Standalone Lens | Lens base URL, such as `http://localhost:4318` | [Dedicated Lens tracing key](../first-trace.md#connect-your-agent) |
| LiteLLM Gateway connected to Lens | Gateway base URL, such as `http://localhost:4000` | LiteLLM virtual key for that gateway |

Keep any path prefix, but leave off the `/v1/traces` suffix. For standalone Lens, for example:

```sh
export LENS_URL="http://localhost:4318"
export LENS_TRACING_KEY="YOUR_LENS_TRACING_KEY"
```

Tracing configuration does not change where model calls go. This example calls OpenAI directly and uses `OPENAI_API_KEY`.

```python
import litellm

litellm.callbacks = ["lens"]

with litellm.trace_agent("support_triage"):
    category = litellm.completion(
        model="gpt-4.1-mini",
        messages=[{"role": "user", "content": "Classify this ticket: I can't reset my password."}],
    ).choices[0].message.content
    litellm.completion(
        model="gpt-4.1-mini",
        messages=[{"role": "user", "content": f"Suggest a next step for this ticket category: {category}"}],
    )
```

In Lens, open **Agents** and select **support_triage**. Each execution of the block appears as one run with two model calls. Calls outside the block still appear in **Traces**, without a named agent run. In async code, use `async with litellm.trace_agent(...)` with `await litellm.acompletion(...)`.

## Related pages

- [Framework examples through LiteLLM](https://docs.litellm.ai/docs/proxy/lens/framework-examples.md)
- [DeepAgents](https://docs.litellm.ai/docs/proxy/lens/integrations/deepagents.md)
