For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/llm_observability/quickstart.md. A documentation index is available at /llms.txt.

Quickstart

This product is not supported for your selected Datadog site. ().

This page demonstrates using Datadog’s Agent Observability SDK to instrument a Python, Node.js, or Java LLM application.

Try Agent Observability locally with lapdog

To try Agent Observability locally, for free, follow the steps to instrument your application and view data locally with lapdog.

Prerequisites

Agent Observability requires a Datadog API key if you don’t have a Datadog Agent running. Find your API key in Datadog.

Instrument Agent Observability with a coding agent

Instrument Agent Observability with a coding agent of your choice by pasting in the following prompt:

Follow the instructions at https://docs.datadoghq.com/llm_observability/instrumentation/agentic.md to instrument my application with Datadog LLM Observability. When configuring the environment, use the following values for variable entries:

DD_SITE=
DD_API_KEY=<your-dd-api-key>

Note: Giving the API key as part of the prompt is optional and not required for the coding agent to instrument your application.

Manual Setup

Follow the setup instructions in Datadog’s in-app onboarding flow for an interactive quickstart experience.

  1. Install the SDK:

    pip install ddtrace
    
  2. Prefix your Python start command with ddtrace-run:

    DD_LLMOBS_ENABLED=1 \
    DD_LLMOBS_ML_APP=quickstart-app \
    DD_SITE=<YOUR_DD_SITE> \
    DD_API_KEY=<YOUR_DATADOG_API_KEY> \
    ddtrace-run <your application command>
    

After enabling, the SDK automatically traces calls to supported Python frameworks such as OpenAI, LangChain, LangGraph, Bedrock, Anthropic, and more. If your framework is not listed, add manual instrumentation to trace your LLM calls directly.

  1. Install the SDK:

    npm install dd-trace
    
  2. Import and initialize dd-trace with Agent Observability as the first dependency in your application entrypoint:

    DD_LLMOBS_ENABLED=1 \
    DD_LLMOBS_ML_APP=quickstart-app \
    DD_SITE=<YOUR_DD_SITE> \
    DD_API_KEY=<YOUR_DATADOG_API_KEY> \
    NODE_OPTIONS="--import dd-trace/initialize.mjs" <your application command>
    

After enabling, the SDK automatically traces calls to supported Node.js frameworks such as OpenAI, LangChain, Vercel AI SDK, Bedrock, Anthropic, and more. If your framework is not listed, add manual instrumentation to trace your LLM calls directly.

Next.js: See Instrument a Next.js Application for Agent Observability for properly configuring your Next.js applications with the Agent Observability SDK.

  1. Install the SDK:

    wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'
    
  2. Add the -javaagent JVM argument to your Java start command:

    java -javaagent:/path/to/dd-java-agent.jar \
    -Ddd.llmobs.enabled=true \
    -Ddd.llmobs.ml.app=quickstart-app \
    -Ddd.site=<YOUR_DD_SITE> \
    -Ddd.api.key=<YOUR_DATADOG_API_KEY> \
    -jar path/to/your/app.jar
    

After enabling, the SDK automatically traces calls to supported Java frameworks. Java auto-instrumentation supports OpenAI and Azure OpenAI. For other libraries such as Bedrock or LangChain4j, use manual instrumentation instead.

For languages other than Python, Node.js, or Java, use the Agent Observability HTTP API to send spans directly to Datadog without an SDK.

If your application emits OpenTelemetry GenAI semantic convention-compliant spans, see OpenTelemetry Instrumentation instead.

Your Datadog site is . Replace <YOUR_DATADOG_API_KEY> with your Datadog API key.

View traces

Make requests to your application triggering LLM calls and then view traces in the Traces tab of the Agent Observability page in Datadog.

If you don’t see any traces:

Next steps

After traces are being submitted from your application, you can:

Example “Hello World” application

See below for a simple application that can be used to begin exploring the Agent Observability product.

  1. Install OpenAI with pip install openai.

  2. Save example script app.py:

    import os
    from openai import OpenAI
    
    oai_client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
    completion = oai_client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
         {"role": "system", "content": "You are a helpful customer assistant for a furniture store."},
         {"role": "user", "content": "I'd like to buy a chair for my living room."},
     ],
    )
    
  3. Run the application:

    DD_LLMOBS_ENABLED=1 \
    DD_LLMOBS_ML_APP=quickstart-app \
    DD_API_KEY=<YOUR_DATADOG_API_KEY> \
    ddtrace-run app.py
    
  1. Install OpenAI with npm install openai.

  2. Save example script app.js:

    const { OpenAI } = require('openai');
    const oaiClient = new OpenAI(process.env.OPENAI_API_KEY);
    
    async function main () {
        const completion = await oaiClient.chat.completions.create({
           model: 'gpt-4o-mini',
           messages: [
              { role: 'system', content: 'You are a helpful customer assistant for a furniture store.' },
              { role: 'user', content: 'I\'d like to buy a chair for my living room.' },
           ]
        });
        return completion;
    }
    
    main().then(console.log)
    
  3. Run the application:

    DD_LLMOBS_ENABLED=1 \
    DD_LLMOBS_ML_APP=quickstart-app \
    DD_API_KEY=<YOUR_DATADOG_API_KEY> \
    NODE_OPTIONS="--import dd-trace/initialize.mjs" node app.js
    

Further Reading