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

Automatic Integrations

AI Guard isn't available in the site.

AI Guard can automatically evaluate LLM calls made through supported AI ecosystem packages, without requiring manual API calls. When your application uses one of the supported packages, the Datadog SDK instruments it to evaluate those calls through AI Guard automatically. No code changes are required.

Supported frameworks and libraries

PackageSupported VersionsSDK Version
LangChain>= 0.1.20>= 3.14.0
OpenAI>= 1.102.0>= 4.10.0
Anthropic>= 0.28.0>= 4.11.0
PackageSupported VersionsSDK Version
AI SDKv6>= 5.95.0
OpenAI>= 4.87.0>= 5.105.0
PackageSupported VersionsSDK Version
RubyLLM>= 1.0.0>= 2.28.0

Set up the Datadog Agent

SDKs use the Datadog Agent to send AI Guard data to Datadog. The Agent must be running and accessible to your application.

If you don't use the Datadog Agent, the AI Guard evaluator API still works, but you can't see AI Guard traces in Datadog.

Required environment variables

Set the following environment variables in your application:

VariableValue
DD_AI_GUARD_ENABLEDtrue
DD_API_KEY<YOUR_API_KEY>
DD_APP_KEY<YOUR_APPLICATION_KEY>
DD_ENV<YOUR_ENVIRONMENT>
DD_SERVICE<YOUR_SERVICE>
DD_TRACE_ENABLEDtrue

By default, automatic integrations follow the blocking configuration set in the AI Guard service settings. To disable blocking for a specific service, set DD_AI_GUARD_BLOCK to false (equivalent to the block option in the SDK and REST API):

VariableValue
DD_AI_GUARD_BLOCKfalse

Integrations

Python

The LangChain integration automatically applies AI Guard evaluations to calls made through the LangChain Python SDK.

Traced operations

AI Guard automatically evaluates the following LangChain operations:

  • LLMs:
    • llm.invoke(), llm.ainvoke()
  • Chat models:
    • chat_model.invoke(), chat_model.ainvoke()
  • Tools:
    • BaseTool.invoke(), BaseTool.ainvoke()

The OpenAI integration automatically applies AI Guard evaluations to calls made through the OpenAI Python SDK.

Traced operations

AI Guard automatically evaluates the following OpenAI operations:

The Anthropic integration automatically applies AI Guard evaluations to calls made through the Anthropic Python SDK.

Traced operations

AI Guard automatically evaluates the following Anthropic operations:

  • Messages:
    • client.messages.create()
    • client.messages.stream()

For the anthropic package >= 0.37.0, AI Guard also evaluates the following beta messages operations:

  • Beta messages:
    • client.beta.messages.create()
    • client.beta.messages.stream()

Node.js

The AI SDK integration automatically applies AI Guard evaluations to text and object generation, embeddings, and tool calls.

Traced operations

The OpenAI integration automatically applies AI Guard evaluations to calls made through the OpenAI Node.js SDK.

Traced operations

AI Guard automatically evaluates the following OpenAI operations:

Note: Streaming requests (stream: true) are not evaluated by AI Guard.

Ruby

The RubyLLM integration automatically applies AI Guard evaluations to chat messages and tool calls.

Traced operations

AI Guard automatically evaluates the following RubyLLM operations:

  • Chat:
    • RubyLLM::Chat#ask
    • RubyLLM::Chat#complete
  • Tool calling:
    • RubyLLM::Chat#handle_tool_calls

Further reading

Additional helpful documentation, links, and articles: