---
title: Automatic Instrumentation for Agent Observability
description: >-
  Enable automatic tracing for LLM frameworks and libraries in your Python or
  Node.js application using Agent Observability integrations.
breadcrumbs: >-
  Docs > Agent Observability > Agent Observability Instrumentation > Automatic
  Instrumentation for Agent Observability
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Automatic Instrumentation for Agent Observability

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Agent Observability can automatically trace and annotate calls to supported LLM frameworks and libraries through various LLM integrations. When you [run your LLM application with the Agent Observability SDK](https://docs.datadoghq.com/llm_observability/quickstart.md), these LLM integrations are enabled by default and provide out-of-the-box traces and observability, without you having to change your code.

{% alert level="info" %}
Automatic instrumentation works for calls to supported frameworks and libraries. To trace other calls (for example: API calls, database queries, internal functions), see the [Agent Observability SDK reference](https://docs.datadoghq.com/llm_observability/instrument/sdk.md) for how to add manual instrumentation.
{% /alert %}

## Set up automatic instrumentation{% #set-up-automatic-instrumentation %}

Configure the [instrumentation environment variables](https://docs.datadoghq.com/llm_observability/instrument.md#configure-environment-variables) before initializing the SDK. Then follow the setup for your language.

{% section title="Instructions for AI agents" %}Apply the guidelines from the [instrumentation overview](https://docs.datadoghq.com/llm_observability/instrument.md) throughout setup. Inspect the installed SDK version and reuse it if it supports the required instrumentation. If an update is required, explain why and ask before changing the dependency. Do not delay instrumentation for an update required only by optional Prompt Management. Use the project's existing package manager, as identified by its lockfiles.{% /section %}

{% tab title="Python" %}

1. Install `ddtrace` with the application's package manager if it is not installed:

   ```bash
   pip install ddtrace
   # Or, for Poetry:
   poetry add ddtrace
   # Or, for uv:
   uv add ddtrace
   ```

1. Load the application's configuration, then import `ddtrace.auto` before other application imports. For an application that uses `python-dotenv`:

   ```python
   from dotenv import load_dotenv
   
   load_dotenv()
   
   import ddtrace.auto
   
   # Import and run the application after SDK initialization.
   ```

If configuration is available before process startup, you can use the [SDK command-line setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=python#command-line-setup) instead. Do not combine application-level configuration loading with `ddtrace-run`.

{% section title="Instructions for AI agents" %}Use the existing configuration-loading mechanism; the example does not require adding `python-dotenv`. Keep `ddtrace.auto` as the first import after any environment or configuration-loading imports. Do not add extraneous comments to application code.{% /section %}

{% /tab %}

{% tab title="Node.js" %}
The Datadog Node.js SDK requires Node.js 22 or later for `dd-trace` 6.x, or Node.js 18 or later for `dd-trace` 5.x. See [Node.js compatibility requirements](https://docs.datadoghq.com/tracing/trace_collection/compatibility/nodejs.md). For Node.js versions earlier than 20.6, follow the [SDK command-line setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=nodejs#command-line-setup) instead of the loader setup below. For Next.js applications, follow the [Next.js instrumentation guide](https://docs.datadoghq.com/llm_observability/guide/nextjs_guide.md) instead of the steps below.

1. Install `dd-trace` with the application's package manager if it is not installed:

   ```bash
   npm install dd-trace
   # Or, for pnpm:
   pnpm add dd-trace
   # Or, for Yarn:
   yarn add dd-trace
   ```

For Node.js 18 or 20, install `dd-trace@5` instead.

1. Configure loader hooks before the Node.js process starts. The hooks instrument supported frameworks that use ESM and TypeScript imports. For example, set `NODE_OPTIONS` in the existing `package.json` startup command:

   ```json
   {
     "scripts": {
       "start": "NODE_OPTIONS=\"--import dd-trace/register.js\" node app.js"
     }
   }
   ```

You can also set the option in an existing `Dockerfile` or startup script. Preserve any other required `NODE_OPTIONS` values.

1. Load configuration, then import `dd-trace/init` before other application imports. For an application that uses `dotenv`:

   ```typescript
   import 'dotenv/config';
   import 'dd-trace/init';
   
   // Import and run the application after SDK initialization.
   ```

For initialization entirely at process startup, see the [SDK command-line setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=nodejs#command-line-setup). Use one initialization method.

{% section title="Instructions for AI agents" %}
Do not apply these instructions to other JavaScript runtimes. For Next.js, follow the [Next.js guide](https://docs.datadoghq.com/llm_observability/guide/nextjs_guide.md) instead.

When using the loader-hook and entrypoint-import method above, set `NODE_OPTIONS="--import dd-trace/register.js"` before the Node.js process starts. Setting it after load time does not work. Use existing startup infrastructure. Load the application's configuration before `dd-trace/init` and keep that import before other application imports. Do not introduce a configuration loader solely to match the example or add extraneous comments.
{% /section %}

{% /tab %}

{% tab title="Java" %}

1. Download the `dd-java-agent` JAR from the [Datadog Java agent releases](https://github.com/DataDog/dd-trace-java/releases).

1. Attach the agent before the application starts by passing a JVM argument:

   ```bash
   java -javaagent:/path/to/dd-java-agent.jar -jar your-application.jar
   ```

For an existing startup script or `Dockerfile`, you can set `JAVA_TOOL_OPTIONS` instead. For example, in a shell:

   ```bash
   export JAVA_TOOL_OPTIONS="-javaagent:/path/to/dd-java-agent.jar"
   ```

Preserve any other required JVM options.

The agent instruments supported LLM providers and frameworks at startup without additional code changes.
{% /tab %}

After setup, [instrument prompts](https://docs.datadoghq.com/llm_observability/instrument.md#instrument-prompts) and run the application to view traces.

## Supported frameworks and libraries{% #supported-frameworks-and-libraries %}

{% tab title="Python" %}

| Framework                              | Supported Versions | Tracer Version |
| -------------------------------------- | ------------------ | -------------- |
| Amazon Bedrock                         | \>= 1.31.57        | \>= 2.9.0      |
| Amazon Bedrock Agents                  | \>= 1.38.26        | \>= 3.10.0     |
| Anthropic                              | \>= 0.28.0         | \>= 2.10.0     |
| Claude Agent SDK                       | \>= 0.0.23         | \>= 4.5.0      |
| CrewAI                                 | \>= 0.105.0        | \>= 3.5.0      |
| Google ADK                             | \>= 1.0.0          | \>= 3.15.0     |
| Google GenAI                           | \>= 1.21.1         | \>= 3.11.0     |
| LangChain                              | \>= 0.1.0          | \>= 2.9.0      |
| LangGraph                              | \>= 0.2.23         | \>= 3.10.1     |
| LiteLLM                                | \>= 1.65.4         | \>= 3.9.0      |
| MCP                                    | \>= 1.10.0         | \>= 3.11.0     |
| MistralAI                              | \>= 2.0.0          | \>= 4.12.0     |
| OpenAI, Azure OpenAI                   | \>= 1.0.0          | \>= 2.9.0      |
| OpenAI Agents                          | \>= 0.0.2          | \>= 3.5.0      |
| Pydantic AI                            | \>= 0.3.0          | \>= 3.11.0     |
| Strands Agents (through OpenTelemetry) | \>= 1.11.0         | Any            |
| Vertex AI                              | \>= 1.71.1         | \>= 2.18.0     |
| vLLM                                   | \>= 0.10.2         | \>= 4.2.0      |

{% /tab %}

{% tab title="Node.js" %}

| Framework            | Supported Versions | Tracer Version                               |
| -------------------- | ------------------ | -------------------------------------------- |
| Amazon Bedrock       | \>= 3.422.0        | \>= 5.35.0 (CJS), >=5.35.0 (ESM)             |
| Anthropic            | \>= 0.14.0         | \>= 5.71.0 (CJS), >=5.71.0 (ESM)             |
| Claude Agent SDK     | \>= 0.2.113        | \>= 5.112.0 (v5), >= 6.1.0 (v6)              |
| LangChain            | \>= 0.1.0          | \>= 5.32.0 (CJS), >=5.38.0 (ESM)             |
| LangGraph            | \>= 1.1.2          | \>= 5.91.0 (CJS), >= 5.91.0 (ESM)            |
| MCP                  | \>= 1.27.1         | \>= 5.99.0 (CJS), >=5.99.0 (ESM)             |
| OpenAI, Azure OpenAI | \>= 3.0.0          | \>= 4.49.0, >= 5.25.0 (CJS), >= 5.38.0 (ESM) |
| OpenAI Agents        | \>= 0.7.0          | \>= 5.118.0 (v5), >= 6.7.0 (v6)              |
| Vercel AI SDK        | \>=4.0.0           | \>= 5.63.0 (CJS), >=5.63.0 (ESM)             |
| VertexAI             | \>= 1.0.0          | \>= 5.44.0 (CJS), >=5.44.0 (ESM)             |
| Google GenAI         | \>= 1.19.0         | \>= 5.81.0 (CJS), >=5.81.0 (ESM)             |

{% collapsible-section #esm-support %}
#### Support for ESMAScript Modules (ESM)

Automatic instrumentation for ESM projects is supported starting from `dd-trace@>=5.38.0`. To enable automatic instrumentation in your ESM projects, use the [command-line setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=nodejs#command-line-setup) and the following Node.js option when running your application:

```bash
--import dd-trace/initialize.mjs
```

For example:

```bash
node --import dd-trace/initialize.mjs app.js
# or
NODE_OPTIONS="--import dd-trace/initialize.mjs" node app.js
```

{% /collapsible-section %}

{% collapsible-section #bundling-support %}
#### Support for bundled applications (esbuild, Webpack)

To use Agent Observability integrations in bundled applications (esbuild, Webpack), you must exclude these integrations' modules from bundling.

##### esbuild{% #esbuild %}

If you are using esbuild, see [Bundling with the Node.js tracer](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs.md#bundling).

##### Webpack{% #webpack %}

For Webpack, specify the corresponding integration in the `externals` section of the webpack configuration:

```javascript
// webpack.config.js
module.exports = {
  resolve: {
    fallback: {
      graphql: false,
    }
  },
  externals: {
    openai: 'openai'
  }
}
```

{% /collapsible-section %}

{% collapsible-section #nextjs-support %}
#### Support for Next.js

See [Instrument a Next.js Application for Agent Observability](https://docs.datadoghq.com/llm_observability/guide/nextjs_guide.md) for properly setting up Agent Observability in your Next.js app.
{% /collapsible-section %}

{% /tab %}

{% tab title="Java" %}

| Framework            | Supported Versions | Tracer Version |
| -------------------- | ------------------ | -------------- |
| OpenAI, Azure OpenAI | \>= 3.0.0          | \>= 1.59.0     |

{% /tab %}

{% alert level="info" %}
Agent Observability also supports any framework that natively emits [OpenTelemetry GenAI semantic convention v1.37+](https://opentelemetry.io/docs/specs/semconv/gen-ai/)-compliant spans, without requiring the Datadog SDK. See [OpenTelemetry Instrumentation](https://docs.datadoghq.com/llm_observability/instrument/otel_instrumentation.md) for setup details and [tested frameworks](https://docs.datadoghq.com/llm_observability/instrument/otel_instrumentation.md#tested-frameworks-and-libraries).
{% /alert %}

## LLM integrations{% #llm-integrations %}

Datadog's LLM integrations capture latency, errors, input parameters, input and output messages, and token usage (when available) for traced calls.

{% collapsible-section #amazon-bedrock %}
### Amazon Bedrock

{% tab title="Python" %}
The [Amazon Bedrock integration](https://docs.datadoghq.com/integrations/amazon-bedrock.md) provides automatic instrumentation for the Amazon Bedrock Runtime Python SDK's chat model calls (using [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html)/[Botocore](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html)).

**Package name:** `boto3` **Integration name:** `botocore`

### Traced methods{% #traced-methods %}

The Amazon Bedrock integration instruments the following methods:

- [Chat messages](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html):
  - `InvokeModel`
- [Streamed chat messages](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html):
  - `InvokeModelWithResponseStream`
- [Chat messages](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html):
  - `Converse` (requires `ddtrace>=3.4.0`)
- [Streamed chat messages](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html):
  - `ConverseStream` (requires `ddtrace>=3.5.0`)

{% alert level="info" %}
The Amazon Bedrock integration does not support tracing embedding calls.
{% /alert %}

{% /tab %}

{% tab title="Node.js" %}
The [Amazon Bedrock integration](https://docs.datadoghq.com/integrations/amazon-bedrock.md) provides automatic tracing for the Amazon Bedrock Runtime Node.js SDK's chat model calls (using [BedrockRuntimeClient](https://www.npmjs.com/package/@aws-sdk/client-bedrock-runtime)).

**Package name:** `@aws-sdk/client-bedrock-runtime` **Integration name:** `aws-sdk`

### Traced methods{% #traced-methods %}

The Amazon Bedrock integration instruments the following methods:

- [Chat messages](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html):
  - `InvokeModel`
  - `InvokeModelWithResponseStream`
- [Conversations](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) (requires `dd-trace>=5.106.0`):
  - `Converse`
  - `ConverseStream`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #amazon-bedrock-agents %}
### Amazon Bedrock Agents

{% tab title="Python" %}
The Amazon Bedrock Agents integration provides automatic tracing for the Amazon Bedrock Agents Runtime Python SDK's agent invoke calls (using [Boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html)/[Botocore](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html)).

**Package name:** `boto3` **Integration name:** `botocore`

### Traced methods{% #traced-methods %}

The Amazon Bedrock Agents integration instruments the following methods:

- [Invoke Agent](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html):
  - `InvokeAgent` (requires ddtrace>=3.10.0)

{% alert level="info" %}
The Amazon Bedrock Agents integration, by default, only traces the overall `InvokeAgent` method. To enable tracing intra-agent steps, you must set `enableTrace=True` in the `InvokeAgent` request parameters.
{% /alert %}

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #anthropic %}
### Anthropic

{% tab title="Python" %}
The [Anthropic integration](https://docs.datadoghq.com/integrations/anthropic.md) provides automatic tracing for the [Anthropic Python SDK's](https://docs.anthropic.com/en/api/client-sdks#python) chat message calls.

**Package name:** `anthropic` **Integration name:** `anthropic`

### Traced methods{% #traced-methods %}

The Anthropic integration instruments the following methods:

- [Chat messages](https://docs.anthropic.com/en/api/messages) (including streamed calls):
  - `Anthropic().messages.create()`, `AsyncAnthropic().messages.create()`
- [Streamed chat messages](https://docs.anthropic.com/en/api/messages-streaming):
  - `Anthropic().messages.stream()`, `AsyncAnthropic().messages.stream()`

{% /tab %}

{% tab title="Node.js" %}
The [Anthropic integration](https://docs.datadoghq.com/integrations/anthropic.md) provides automatic tracing for the [Anthropic Node.js SDK's](https://docs.claude.com/en/api/client-sdks#typescript) chat message calls.

**Package name:** `@anthropic-ai/sdk` **Integration name:** `anthropic`

### Traced methods{% #traced-methods %}

The Anthropic integration instruments the following methods:

- [Chat messages](https://docs.anthropic.com/en/api/messages) (including streamed calls):
  - `anthropic.messages.create()`
- [Streamed chat messages](https://docs.anthropic.com/en/api/messages-streaming):
  - `anthropic.messages.stream()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #claude-agent-sdk %}
### Claude Agent SDK

{% tab title="Python" %}
The Claude Agent SDK integration provides automatic tracing for agent queries made through the [Claude Agent SDK for Python](https://github.com/anthropics/claude-agent-sdk-python).

**Package name:** `claude-agent-sdk` **Integration name:** `claude_agent_sdk`

### Traced methods{% #traced-methods %}

The Claude Agent SDK integration instruments the following methods:

- [One-shot queries](https://github.com/anthropics/claude-agent-sdk-python?tab=readme-ov-file#basic-usage):
  - `claude_agent_sdk.query()`
- [Interactive client queries](https://github.com/anthropics/claude-agent-sdk-python?tab=readme-ov-file#with-claudesdkclient-continuous-conversation):
  - `ClaudeSDKClient.query()` (finished by `ClaudeSDKClient.receive_messages()`)

{% /tab %}

{% tab title="Node.js" %}
The Claude Agent SDK integration automatically traces agent queries made through the [Claude Agent SDK for TypeScript](https://code.claude.com/docs/en/agent-sdk/typescript).

**Package name:** `@anthropic-ai/claude-agent-sdk` **Integration name:** `claude-agent-sdk`

### Traced methods{% #traced-methods %}

The integration instruments `query()` and records agent runs, agent steps, LLM calls, tool calls, and subagent activity.

The SDK is an ES module. Follow the ESM setup instructions to enable automatic instrumentation.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #crewai %}
### CrewAI

{% tab title="Python" %}
The [CrewAI integration](https://docs.datadoghq.com/integrations/crewai.md) automatically traces execution of Crew kickoffs, including task/agent/tool invocations, made through [CrewAI's Python SDK](https://docs.crewai.com/introduction).

**Package name:** `crewai` **Integration name:** `crewai`

### Traced methods{% #traced-methods %}

The CrewAI integration instruments the following methods:

- [Crew Kickoff](https://docs.crewai.com/concepts/crews#kicking-off-a-crew):

  - `crew.kickoff()`
  - `crew.kickoff_async()`
  - `crew.kickoff_for_each()`
  - `crew.kickoff_for_each_async()`

- [Task Execution](https://docs.crewai.com/concepts/tasks):

  - `task.execute_sync()`
  - `task.execute_async()`

- [Agent Execution](https://docs.crewai.com/concepts/agents):

  - `agent.execute_task()`

- [Tool Invocation](https://docs.crewai.com/concepts/tools):

  - `tool.invoke()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #google-adk %}
### Google ADK

{% tab title="Python" %}
The Google ADK integration provides automatic tracing for agent runs, tool calls, and code executions made through [Google's ADK Python SDK](https://google.github.io/adk-docs/#python).

**Package name:** `google-adk` **Integration name:** `google_adk`

### Traced methods{% #traced-methods %}

The Google ADK integration instruments the following methods:

- [Agent Runs](https://google.github.io/adk-docs/agents/)
- [Tool Calls](https://google.github.io/adk-docs/tools)
- [Code Executions](https://google.github.io/adk-docs/agents/llm-agents/#code-execution)

Both `run_live` and `run_async` methods are supported.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #google-genai %}
### Google GenAI

{% tab title="Python" %}
The Google GenAI integration automatically traces methods in the [Google GenAI Python SDK](https://ai.google.dev/gemini-api/docs).

**Package name:** `google-genai` **Integration name:** `google_genai`

**Note:** The [Google GenAI Python SDK](https://ai.google.dev/gemini-api/docs) succeeds the Google GenerativeAI SDK, and exposes both Gemini Developer API as well as Vertex.

### Traced methods{% #traced-methods %}

The Google GenAI integration instruments the following methods:

- [Generating content](https://ai.google.dev/api/generate-content#method:-models.generatecontent) (including streamed calls):
  - `models.generate_content()` (Also captures `chat.send_message()`)
  - `aio.models.generate_content()` (Also captures `aio.chat.send_message()`)
- [Embedding content](https://ai.google.dev/api/embeddings#method:-models.embedcontent) -`models.embed_content()` -`aio.models.embed_content()`

{% /tab %}

{% tab title="Node.js" %}
The Google GenAI integration automatically traces methods in the [Google GenAI Node.js SDK](https://ai.google.dev/gemini-api/docs#javascript) by instrumenting the [`@google/genai` package](https://www.npmjs.com/package/@google/genai).

**Note:** The [Google GenAI Node.js SDK](https://ai.google.dev/gemini-api/docs#javascript) succeeds the [Google GenerativeAI SDK](https://www.npmjs.com/package/@google/generative-ai), and exposes both Gemini Developer API as well as Vertex.

**Package name:** `@google/genai` **Integration name:** `google-genai`

### Traced methods{% #traced-methods %}

The Google GenAI integration instruments the following methods:

- [Generating content](https://ai.google.dev/api/generate-content#text_gen_text_only_prompt-JAVASCRIPT) (including [streamed calls](https://ai.google.dev/api/generate-content#text_gen_text_only_prompt_streaming-JAVASCRIPT))
- [Embedding content](https://ai.google.dev/api/embeddings#embed_content-JAVASCRIPT)

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #langchain %}
### LangChain

{% tab title="Python" %}
The [LangChain integration](https://docs.datadoghq.com/integrations/langchain.md) provides automatic tracing for the [LangChain Python SDK's](https://python.langchain.com/docs/introduction/) LLM, chat model, and chain calls.

**Package name:** `langchain`, `langchain_openai`, `langchain_anthropic`, and [other langchain partner packages](https://docs.langchain.com/oss/python/integrations/providers/all_providers) **Integration name:** `langchain`

### Traced methods{% #traced-methods %}

The LangChain integration instruments the following methods:

- [LLMs](https://python.langchain.com/v0.2/docs/concepts/#llms):

  - `llm.invoke()`, `llm.ainvoke()`
  - `llm.stream()`, `llm.astream()`

- [Chat models](https://python.langchain.com/docs/concepts/chat_models/)

  - `chat_model.invoke()`, `chat_model.ainvoke()`
  - `chat_model.stream()`, `chat_model.astream()`

- [Chains/LCEL](https://python.langchain.com/docs/concepts/runnables/)

  - `chain.invoke()`, `chain.ainvoke()`
  - `chain.batch()`, `chain.abatch()`
  - `chain.stream()`, `chain.astream()`

- [Embeddings](https://python.langchain.com/docs/concepts/embedding_models/)

  - OpenAI : `OpenAIEmbeddings.embed_documents()`, `OpenAIEmbeddings.embed_query()`

- [Tools](https://python.langchain.com/docs/concepts/tools/)

  - `BaseTool.invoke()`, `BaseTool.ainvoke()`

- [Retrieval](https://python.langchain.com/docs/concepts/retrieval/)

  - `langchain_community.<vectorstore>.similarity_search()`
  - `langchain_pinecone.similarity_search()`

- [Prompt Templating](https://docs.langchain.com/langsmith/manage-prompts-programmatically#pull-a-prompt)

  - `BasePromptTemplate.invoke()`, `BasePromptTemplate.ainvoke()`
Important alert (level: info): For best results, assign templates to variables with meaningful names. Automatic instrumentation uses these names to identify prompts.
  ```python
  # "translation_template" will be used to identify the template in Datadog
  translation_template = PromptTemplate.from_template("Translate {text} to {language}")
  chain = translation_template | llm
  ```

{% /tab %}

{% tab title="Node.js" %}
The [LangChain integration](https://docs.datadoghq.com/integrations/langchain.md) provides automatic tracing for the [LangChain Node.js SDK's](https://js.langchain.com/docs/introduction/) LLM, chat model, chain, embedding, tool, and vector store calls.

**Package name:** `langchain`, `@langchain/openai`, `@langchain/anthropic`, and [other langchain partner packages](https://docs.langchain.com/oss/javascript/integrations/providers/all_providers) **Integration name:** `langchain`

### Traced methods{% #traced-methods %}

The LangChain integration instruments the following methods:

- [LLMs](https://js.langchain.com/docs/integrations/llms/):
  - `llm.invoke()`
- [Chat models](https://js.langchain.com/docs/concepts/chat_models)
  - `chat_model.invoke()`
- [Chains](https://js.langchain.com/docs/how_to/sequence/)
  - `chain.invoke()`
  - `chain.batch()`
- [Embeddings](https://js.langchain.com/docs/integrations/text_embedding/)
  - `embeddings.embedQuery()`
  - `embeddings.embedDocuments()`
- Tools (requires `dd-trace>=5.59.0`):
  - `tool.invoke()`
- Vector stores (requires `dd-trace>=5.59.0`):
  - `vectorStore.similaritySearch()`
  - `vectorStore.similaritySearchWithScore()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #langgraph %}
### LangGraph

{% tab title="Python" %}
The LangGraph integration automatically traces `Pregel/CompiledGraph` and `RunnableSeq (node)` invocations made through the [LangGraph Python SDK](https://langchain-ai.github.io/langgraph/concepts/sdk/).

**Package name:** `langgraph` **Integration name:** `langgraph`

### Traced methods{% #traced-methods %}

The LangGraph integration instruments synchronous and asynchronous versions of the following methods:

- [CompiledGraph.invoke(), Pregel.invoke(), CompiledGraph.stream(), Pregel.stream()](https://blog.langchain.dev/langgraph/#compile)
- [RunnableSeq.invoke()](https://blog.langchain.dev/langgraph/#nodes)

{% /tab %}

{% tab title="Node.js" %}
The LangGraph integration automatically traces graph execution through the [LangGraph JavaScript SDK](https://docs.langchain.com/oss/javascript/langgraph/overview).

**Package name:** `@langchain/langgraph` **Integration name:** `langgraph`

### Traced methods{% #traced-methods %}

The integration instruments `Pregel.stream()`, which also captures compiled graph calls:

- `graph.invoke()`
- `graph.stream()`

The integration creates a workflow span for the graph. The LangChain integration records child workflow spans for graph nodes.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #litellm %}
### LiteLLM

{% tab title="Python" %}
The [LiteLLM integration](https://docs.datadoghq.com/integrations/litellm.md) provides automatic tracing for the [LiteLLM Python SDK](https://docs.litellm.ai/docs/#litellm-python-sdk) and [proxy server router methods](https://docs.litellm.ai/docs/routing).

**Package name:** `litellm` **Integration name:** `litellm`

### Traced methods{% #traced-methods %}

The LiteLLM integration instruments the following methods:

- [Chat Completions](https://docs.litellm.ai/docs/completion) (including streamed calls):
  - `litellm.completion`
  - `litellm.acompletion`
- [Completions](https://docs.litellm.ai/docs/text_completion) (including streamed calls):
  - `litellm.text_completion`
  - `litellm.atext_completion`
- Router Chat Completions (including streamed calls):
  - `router.Router.completion`
  - `router.Router.acompletion`
- Router Completions (including streamed calls):
  - `router.Router.text_completion`
  - `router.Router.atext_completion`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #mcp %}
### MCP

{% tab title="Python" %}
The Model Context Protocol (MCP) integration instruments client and server tool calls in the [MCP](https://modelcontextprotocol.io/docs/getting-started/intro) SDK.

**Package name:** `mcp` **Integration name:** `mcp`

### Traced methods{% #traced-methods %}

The MCP integration instruments both MCP clients and servers.

#### MCP clients{% #mcp-clients %}

The MCP client-side instrumentation records client tool calls.

- [Client Tool Calls](https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#writing-mcp-clients):
  - `mcp.client.session.ClientSession.call_tool`

#### MCP servers{% #mcp-servers %}

The MCP server-side integration instruments [`initialize`](https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#initialization) and [`tools/call`](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#calling-tools) MCP methods. [`tools/list`](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#listing-tools) calls are optionally intercepted when intent capture is enabled.

The following tags are recorded on server spans:

- `mcp_method`: The MCP method called.

- `mcp_session_id`: The MCP [session ID](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports#session-management), recorded when available in the request.

- `client_name`: The name of the client as provided to `initialize`.

- `client_version`: The version of the client as provided to `initialize`.

- Server methods instrumented:

  - `mcp.server.shared.session.RequestResponder.__enter__`
  - `mcp.server.shared.session.RequestResponder.__exit__`
  - `mcp.server.shared.session.RequestResponder.respond`

{% /tab %}

{% tab title="Node.js" %}
The Model Context Protocol (MCP) integration instruments client tool calls in the [MCP JavaScript SDK](https://github.com/modelcontextprotocol/typescript-sdk).

**Package name:** `@modelcontextprotocol/sdk` **Integration name:** `modelcontextprotocol-sdk`

### Traced methods{% #traced-methods %}

The MCP integration instruments the following methods:

- [Client Tool Calls](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/client.md#tools):
  - `Client.callTool()`
  - `Client.listTools()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #mistralai %}
### MistralAI

{% tab title="Python" %}
The MistralAI integration provides automatic tracing for the [MistralAI Python SDK's](https://docs.mistral.ai/getting-started/clients) chat completion and embedding calls.

**Package name:** `mistralai` **Integration name:** `mistralai`

### Traced methods{% #traced-methods %}

The MistralAI integration instruments the following methods:

- [Chat completions](https://docs.mistral.ai/api/#tag/chat/operation/chat_completion_v1_chat_completions_post):
  - `Chat.complete()`, `Chat.complete_async()`
- [Streamed chat completions](https://docs.mistral.ai/api/#tag/chat/operation/chat_completion_v1_chat_completions_post):
  - `Chat.stream()`, `Chat.stream_async()`
- [Embeddings](https://docs.mistral.ai/api/#tag/embeddings/operation/embeddings_v1_embeddings_post):
  - `Embeddings.create()`, `Embeddings.create_async()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #openai %}
### OpenAI, Azure OpenAI

{% tab title="Python" %}
The [OpenAI integration](https://docs.datadoghq.com/integrations/openai.md) provides automatic tracing for the [OpenAI Python SDK's](https://platform.openai.com/docs/api-reference/introduction) completion and chat completion endpoints to OpenAI and Azure OpenAI.

**Package name:** `openai` **Integration name:** `openai`

### Traced methods{% #traced-methods %}

The OpenAI integration instruments the following methods, including streamed calls:

- [Completions](https://platform.openai.com/docs/api-reference/completions):
  - `OpenAI().completions.create()`, `AzureOpenAI().completions.create()`
  - `AsyncOpenAI().completions.create()`, `AsyncAzureOpenAI().completions.create()`
- [Chat completions](https://platform.openai.com/docs/api-reference/chat):
  - `OpenAI().chat.completions.create()`, `AzureOpenAI().chat.completions.create()`
  - `AsyncOpenAI().chat.completions.create()`, `AsyncAzureOpenAI().chat.completions.create()`
- [Responses](https://platform.openai.com/docs/api-reference/responses):
  - `OpenAI().responses.create()`
  - `AsyncOpenAI().responses.create()`
  - `OpenAI().responses.parse()` (as of `ddtrace==3.17.0`)
  - `AsyncOpenAI().responses.parse()` (as of `ddtrace==3.17.0`)
- [Calls made to DeepSeek through the OpenAI Python SDK](https://api-docs.deepseek.com/) (as of `ddtrace==3.1.0`)

{% /tab %}

{% tab title="Node.js" %}
The [OpenAI integration](https://docs.datadoghq.com/integrations/openai.md) provides automatic tracing for the [OpenAI Node.js SDK's](https://platform.openai.com/docs/api-reference/introduction) completion, chat completion, embeddings, and Responses endpoints to OpenAI and [Azure OpenAI](https://www.npmjs.com/package/openai#microsoft-azure-openai).

**Package name:** `openai` **Integration name:** `openai`

### Traced methods{% #traced-methods %}

The OpenAI integration instruments the following methods, including streamed calls:

- [Completions](https://platform.openai.com/docs/api-reference/completions):
  - `openai.completions.create()` and `azureopenai.completions.create()`
- [Chat completions](https://platform.openai.com/docs/api-reference/chat):
  - `openai.chat.completions.create()` and `azureopenai.chat.completions.create()`
- [Embeddings](https://platform.openai.com/docs/api-reference/embeddings):
  - `openai.embeddings.create()` and `azureopenai.embeddings.create()`
- [Calls made to DeepSeek through the OpenAI Node.js SDK](https://api-docs.deepseek.com/) (as of `dd-trace@5.42.0`)
- [Responses](https://platform.openai.com/docs/api-reference/responses)
  - `openai.responses.create()` (as of `dd-trace@5.76.0`)

The integration also traces `openai.decisions.create()` calls. Decisions tracing requires `openai>=7.30.0`, as well as either `dd-trace>=5.133.0` on v5, or `>=6.22.0` on v6.
{% /tab %}

{% tab title="Java" %}
The [OpenAI integration](https://docs.datadoghq.com/integrations/openai.md) provides automatic tracing for the [OpenAI Java SDK's](https://platform.openai.com/docs/api-reference/introduction) completion, chat completion, embeddings, and responses endpoints to OpenAI and Azure OpenAI.

### Traced methods{% #traced-methods %}

The OpenAI integration instruments the following methods on `OpenAIClient`, including streamed calls:

- [Completions](https://platform.openai.com/docs/api-reference/completions):
  - `openAiClient.completions().create()`
  - `openAiClient.completions().createStreaming()`
  - `openAiClient.async().completions().create()`
  - `openAiClient.async().completions().createStreaming()`
- [Chat completions](https://platform.openai.com/docs/api-reference/chat):
  - `openAiClient.chat().completions().create()`
  - `openAiClient.chat().completions().createStreaming()`
  - `openAiClient.async().chat().completions().create()`
  - `openAiClient.async().chat().completions().createStreaming()`
- [Embeddings](https://platform.openai.com/docs/api-reference/embeddings):
  - `openAiClient.embeddings().create()`
  - `openAiClient.async().embeddings().create()`
- [Responses](https://platform.openai.com/docs/api-reference/responses):
  - `openAiClient.responses().create()`
  - `openAiClient.responses().createStreaming()`
  - `openAiClient.async().responses().create()`
  - `openAiClient.async().responses().createStreaming()`

The provider (OpenAI vs Azure OpenAI) is automatically detected based on the `baseUrl` configured in `ClientOptions`. All methods support both blocking and async (CompletableFuture-based) variants.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #openai-agents %}
### OpenAI Agents

{% tab title="Python" %}
The OpenAI Agents integration converts the [built-in tracing](https://openai.github.io/openai-agents-python/tracing/) from the [OpenAI Agents SDK](https://openai.github.io/openai-agents-python/) into Agent Observability format and sends it to Agent Observability product by adding a Datadog trace processor.

**Package name:** `openai-agents` **Integration name:** `openai_agents`

The following operations are supported:

- [`traces`](https://openai.github.io/openai-agents-python/ref/tracing/traces/)
- [`agent`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.agent_span)
- [`generation`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.generation_span) using Datadog's OpenAI integration
- [`response`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.response_span)
- [`guardrail`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.guardrail_span)
- [`handoff`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.handoff_span)
- [`function`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.function_span)
- [`custom`](https://openai.github.io/openai-agents-python/ref/tracing/#agents.tracing.custom_span)

{% /tab %}

{% tab title="Node.js" %}
The OpenAI Agents integration adds a Datadog trace processor to the [OpenAI Agents SDK for JavaScript](https://openai.github.io/openai-agents-js/guides/tracing/). It converts the SDK's built-in traces and spans into Agent Observability traces.

**Package name:** `@openai/agents` **Integration name:** `openai-agents`

The integration supports the following operations, including streamed agent runs:

- Traces (workflows)
- Agent runs
- LLM generations and responses
- Guardrails
- Handoffs
- Function tools
- Custom spans

Keep the SDK's [built-in tracing](https://openai.github.io/openai-agents-js/guides/tracing/) enabled so the Datadog trace processor receives these operations.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #pydantic-ai %}
### Pydantic AI

{% tab title="Python" %}
The Pydantic AI integration instruments agent invocations and tool calls made using the [Pydantic AI](https://ai.pydantic.dev/) agent framework.

**Package name:** `pydantic-ai` **Integration name:** `pydantic_ai`

### Traced methods{% #traced-methods %}

The Pydantic AI integration instruments the following methods:

- [Agent Invocations](https://ai.pydantic.dev/agents/) (including any tools or toolsets associated with the agent):
  - `agent.Agent.iter` (also traces `agent.Agent.run` and `agent.Agent.run_sync`)
  - `agent.Agent.run_stream`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #strands-agents %}
### Strands Agents

{% tab title="Python" %}
Starting from [v1.11.0](https://github.com/strands-agents/sdk-python/releases/tag/v1.11.0), [Strands Agents](https://strandsagents.com) natively emits spans compliant with [OpenTelemetry GenAI semantic conventions v1.37](https://opentelemetry.io/docs/specs/semconv/gen-ai/), which Agent Observability automatically ingests without requiring the Datadog SDK.

For setup instructions and a complete example, see [OpenTelemetry Instrumentation — Using Strands Agents](https://docs.datadoghq.com/llm_observability/instrument/otel_instrumentation.md#using-strands-agents).
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #vercel-ai-sdk %}
### Vercel AI SDK

{% tab title="Node.js" %}
The [Vercel AI SDK](https://docs.datadoghq.com/integrations/vercel-ai-sdk.md) integration automatically traces text and object generation, embeddings, and tool calls by intercepting the OpenTelemetry spans created by the underlying core [Vercel AI SDK](https://ai-sdk.dev/docs/introduction) and converting them into Agent Observability spans.

**Package name:** `ai` **Integration name:** `ai`

### Traced methods{% #traced-methods %}

- [Text generation](https://ai-sdk.dev/docs/ai-sdk-core/generating-text):
  - `generateText`
  - `streamText`
- [Object generation](https://ai-sdk.dev/docs/ai-sdk-core/generating-structured-data):
  - `generateObject`
  - `streamObject`
- [Embedding](https://ai-sdk.dev/docs/ai-sdk-core/embeddings):
  - `embed`
  - `embedMany`
- [Tool calling](https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling):
  - `tool.execute`

### Vercel AI Core SDK telemetry{% #vercel-ai-core-sdk-telemetry %}

This integration automatically patches the tracer passed into each of the traced methods under the [`experimental_telemetry` option](https://ai-sdk.dev/docs/ai-sdk-core/telemetry). If no `experimental_telemetry` configuration is passed in, the integration enables it to still send Agent Observability spans.

```javascript
require('dd-trace').init({
  llmobs: {
    mlApp: 'my-ml-app',
  }
});

const { generateText } = require('ai');
const { openai } = require('@ai-sdk/openai');

async function main () {
  let result = await generateText({
    model: openai('gpt-4o'),
    ...
    experimental_telemetry: {
      isEnabled: true,
      tracer: someTracerProvider.getTracer('ai'), // this tracer will be patched to format and send created spans to Agent Observability
    }
  });

  result = await generateText({
    model: openai('gpt-4o'),
    ...
  }); // since no tracer is passed in, the integration will enable it to still send Agent Observability spans
}
```

**Note**: If `experimental_telemetry.isEnabled` is set to `false`, the integration does not turn it on, and does not send spans to Agent Observability.
{% /tab %}

{% /collapsible-section %}

{% collapsible-section #vertex-ai %}
### Vertex AI

{% tab title="Python" %}
The [Vertex AI integration](https://docs.datadoghq.com/integrations/google-cloud-vertex-ai.md) automatically traces content generation and chat message calls made through [Google's Vertex AI Python SDK](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest).

**Package name:** `vertexai` **Integration name:** `vertexai`

### Traced methods{% #traced-methods %}

The Vertex AI integration instruments the following methods:

- [Generating content](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest/summary_method#vertexai_preview_generative_models_GenerativeModel_generate_content_summary) (including streamed calls):

  - `model.generate_content()`
  - `model.generate_content_async()`

- [Chat Messages](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest/summary_method#vertexai_generative_models_ChatSession_send_message_summary) (including streamed calls):

  - `chat.send_message()`
  - `chat.send_message_async()`

{% /tab %}

{% tab title="Node.js" %}
The [Vertex AI integration](https://docs.datadoghq.com/integrations/google-cloud-vertex-ai.md) automatically traces content generation and chat message calls made through [Google's Vertex AI Node.js SDK](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/nodejs/latest).

**Package name:** `@google-cloud/vertexai` **Integration name:** `google-cloud-vertexai`

### Traced methods{% #traced-methods %}

The Vertex AI integration instruments the following methods:

- [Generating content](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/nodejs/latest#send-text-prompt-requests):
  - `model.generateContent()`
  - `model.generateContentStream()`
- [Chat Messages](https://cloud.google.com/vertex-ai/generative-ai/docs/reference/nodejs/latest#send-multiturn-chat-requests):
  - `chat.sendMessage()`
  - `chat.sendMessageStream()`

{% /tab %}

{% /collapsible-section %}

{% collapsible-section #vllm %}
### vLLM

{% tab title="Python" %}
The vLLM integration automatically traces request processing and token generation in the [vLLM](https://docs.vllm.ai/) inference engine. It captures model name, input and output tokens, and latency metrics (time to first token, queue time, prefill time, decode time, and inference time).

**Package name:** `vllm` **Integration name:** `vllm`

### Traced methods{% #traced-methods %}

The vLLM integration instruments the following methods on both `LLMEngine` (offline) and `AsyncLLM` (online):

- Input processing:
  - `Processor.process_inputs`
- Output processing:
  - `OutputProcessor.process_outputs`

{% /tab %}

{% /collapsible-section %}

## Enable or disable LLM integrations{% #enable-or-disable-llm-integrations %}

All integrations are **enabled by default**.

### Disable all LLM integrations{% #disable-all-llm-integrations %}

{% tab title="Python" %}
Use the [in-code SDK setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=python#in-code-setup) and specify `integrations_enabled=False`.

**Example**: In-code SDK setup that disables all LLM integrations

```python
from ddtrace.llmobs import LLMObs

LLMObs.enable(
  ml_app="<YOUR_ML_APP_NAME>",
  api_key="<YOUR_DATADOG_API_KEY>",
  integrations_enabled=False
)
```

{% /tab %}

{% tab title="Node.js" %}
Use the [in-code SDK setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=nodejs#in-code-setup) and specify `plugins: false`.

**Example**: In-code SDK setup that disables all LLM integrations

```javascript
const tracer = require('dd-trace').init({
  llmobs: { ... },
  plugins: false
});
const { llmobs } = tracer;
```

{% /tab %}

### Only enable specific LLM integrations{% #only-enable-specific-llm-integrations %}

{% tab title="Python" %}

1. Use the [in-code SDK setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=python#in-code-setup) and disable all integrations with `integrations_enabled=False`.
1. Manually enable select integrations with `ddtrace.patch()`.

**Example**: In-code SDK setup that only enables the LangChain integration

```python
from ddtrace import patch
from ddtrace.llmobs import LLMObs

LLMObs.enable(
  ml_app="<YOUR_ML_APP_NAME>",
  api_key="<YOUR_DATADOG_API_KEY>",
  integrations_enabled=False
)

patch(langchain=True)
```

{% /tab %}

{% tab title="Node.js" %}

1. Use the [in-code SDK setup](https://docs.datadoghq.com/llm_observability/instrument/sdk.md?tab=nodejs#in-code-setup) and disable all integrations with `plugins: false`.
1. Manually enable select integrations with `use()`.

**Example**: In-code SDK setup that only enables the LangChain integration

```javascript
const tracer = require('dd-trace').init({
  llmobs: { ... },
  plugins: false
});
const { llmobs } = tracer;
tracer.use('langchain', true);
```

{% /tab %}

For more specific control over library patching and the integration that starts the span, you can set the following environment variables:

{% tab title="Python" %}

{% dl %}

{% dt %}
`DD_PATCH_MODULES`
{% /dt %}

{% dd %}
A comma-separated list of modules to enable or disable patching for. Overrides the default patching behavior. Use the format `module:true,module:false`. Available in version 2.17.4+. **Example**: `DD_PATCH_MODULES=openai:false,langchain:false`
{% /dd %}

{% /dl %}

{% /tab %}

{% tab title="Node.js" %}

{% dl %}

{% dt %}
`DD_TRACE_DISABLED_INSTRUMENTATIONS`
{% /dt %}

{% dd %}
A comma-separated string of library names that are not patched when the tracer is initialized. **Example**: `DD_TRACE_DISABLED_INSTRUMENTATIONS=openai,http`
{% /dd %}

{% /dl %}

{% /tab %}

## Further Reading{% #further-reading %}

Additional helpful documentation, links, and articles:

- [Agent Observability SDK Reference](https://docs.datadoghq.com/llm_observability/instrument/sdk.md)
- [Track, compare, and optimize your LLM prompts with Datadog LLM Observability](https://www.datadoghq.com/blog/llm-prompt-tracking)
- [Gain end-to-end visibility into MCP clients with Datadog LLM Observability](https://www.datadoghq.com/blog/mcp-client-monitoring)
