The Atatus Python agent can trace the LLM calls your application makes. Every request to a model becomes a span alongside your existing HTTP and database spans, so an LLM call shows up in the same trace as the request that triggered it. This page is for developers already running the Atatus Python agent, or about to install it. LLM monitoring was added in agent version 2.1.0.

Install

LLM monitoring ships as an optional extra. Install the agent with it:
The extra brings the instrumentation for every library in Supported libraries, so there is nothing to add per library.
If you turn LLM monitoring on without the extra, the agent logs a warning that it is unable to instrument LLMOBS and carries on without it. Your application is not affected.

Enable LLM monitoring

Add LLMOBS next to your license key and app name. This example is for Django, in your settings.py:
settings.py
Or use an environment variable:
For Flask, FastAPI, and other frameworks, set the same LLMOBS key wherever you configure the agent. See the Python agent installation guides for where that is. Restart your application after the change. The agent must start before the LLM libraries are used, which is the same rule as the rest of the agent.

Supported libraries

These are traced automatically when the library is installed in your environment.

Group calls with decorators

By default each model call is its own span. To group calls into a workflow, an agent, or a tool call you define yourself, wrap your functions with the decorators:
The decorators are workflow, task, agent, and tool. Each one works on sync and async functions, and the spans nest under the call that started them. See Span kinds for how each kind is shown.

Where the data appears

Your application shows up under both APM and LLM in the dashboard. The APM views are unchanged, and the LLM views add the model, token, cost, and prompt detail. An application appears under LLM only after it has sent its first LLM span, so make a call through one of the traced libraries before looking for it.

Next steps