LLM 추론 실행
https://api.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.us3.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.us5.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.datadoghq.eu/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.ap1.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.ap2.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.uk1.datadoghq.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.ddog-gov.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inferencehttps://api.us2.ddog-gov.com/api/v2/llm-obs/v1/integrations/{integration}/{account_id}/inference개요
지정된 통합 및 계정을 통해 LLM 추론 요청을 실행하고 모델 응답과 토큰 사용량을 반환합니다.
인수
경로 파라미터
integration [required]The name of the LLM integration.
openai, amazon_bedrock, anthropic, azure_openai, vertex_ai, llmproxyaccount_id [required]The ID of the integration account.
요청
Body Data (required)
추론 요청 파라미터입니다.
anthropic_metadataLLM 추론 요청을 위한 파라미터입니다.
effortThe effort level for Anthropic inference.
low, medium, high, maxthinkingConfiguration for Anthropic extended thinking feature.
budget_tokensMaximum token budget for extended thinking. Required when type is enabled.
type [required]The thinking mode for Anthropic extended thinking.
enabled, disabled, adaptiveazure_openai_metadataAzure OpenAI-specific metadata for an integration account or inference request.
deployment_idThe Azure OpenAI deployment ID.
model_versionThe model version deployed in Azure.
resource_nameThe Azure OpenAI resource name.
bedrock_metadataAmazon Bedrock-specific metadata for an inference request.
regionThe AWS region for the Bedrock request.
frequency_penaltyPenalty for token frequency to reduce repetition.
json_schemaJSON schema for structured output, if supported by the model.
max_completion_tokensMaximum number of completion tokens to generate (alternative to max_tokens for some providers).
max_tokensMaximum number of tokens to generate.
messages [required]List of messages in an inference conversation.
contentPlain text content of the message.
contentsList of structured content blocks in a message.
type [required]The content block type.
value [required]The typed value of a message content block.
textPlain text content.
tool_callA tool call made during LLM inference.
argumentsThe arguments passed to the tool.
nameThe name of the tool being called.
tool_idUnique identifier for the tool call.
typeThe type of tool call.
tool_call_resultThe result returned by a tool call during LLM inference.
nameThe name of the tool that produced this result.
resultThe result content returned by the tool.
tool_idIdentifier matching the corresponding tool call.
typeThe type of tool result.
idUnique identifier for the message.
roleThe role of the message author.
tool_callsList of tool calls in a message.
argumentsThe arguments passed to the tool.
nameThe name of the tool being called.
tool_idUnique identifier for the tool call.
typeThe type of tool call.
tool_resultsList of tool results in a message.
nameThe name of the tool that produced this result.
resultThe result content returned by the tool.
tool_idIdentifier matching the corresponding tool call.
typeThe type of tool result.
model_id [required]The model identifier to use for inference.
openai_metadataOpenAI-specific metadata for an inference request.
reasoning_effortThe reasoning effort level for OpenAI models that support it.
none, low, medium, high, xhighreasoning_summaryThe verbosity of the reasoning summary.
auto, concise, detailedpresence_penaltyPenalty for token presence to encourage topic diversity.
temperatureSampling temperature between 0 and 2. Higher values produce more random output.
toolsList of tools available to the model.
function [required]A function definition for a tool available to the model.
descriptionA description of what the function does.
name [required]The name of the function.
parameters [required]JSON schema describing the function parameters.
type [required]The type of tool.
top_kTop-K sampling parameter.
top_pNucleus sampling probability mass.
vertex_ai_metadataVertex AI-specific metadata for an integration account or inference request.
locationThe Vertex AI region.
projectThe Google Cloud project ID.
project_idsList of Google Cloud project IDs available to the service account.
{
"anthropic_metadata": {
"effort": "medium",
"thinking": {
"budget_tokens": 1024,
"type": "enabled"
}
},
"azure_openai_metadata": {
"deployment_id": "my-gpt4-deployment",
"model_version": "0613",
"resource_name": "my-azure-resource"
},
"bedrock_metadata": {
"region": "us-east-1"
},
"frequency_penalty": 0,
"json_schema": "{\"type\":\"object\",\"properties\":{\"answer\":{\"type\":\"string\"}}}",
"max_completion_tokens": 1024,
"max_tokens": 1024,
"messages": [
{
"content": "What is the capital of France?",
"contents": [
{
"type": "text",
"value": {
"text": "Hello, how can I help you?",
"tool_call": {
"arguments": {
"location": "San Francisco"
},
"name": "get_weather",
"tool_id": "call_abc123",
"type": "function"
},
"tool_call_result": {
"name": "get_weather",
"result": "The weather in San Francisco is 68°F and sunny.",
"tool_id": "call_abc123",
"type": "function"
}
}
}
],
"id": "msg_001",
"role": "user",
"tool_calls": [
{
"arguments": {
"location": "San Francisco"
},
"name": "get_weather",
"tool_id": "call_abc123",
"type": "function"
}
],
"tool_results": [
{
"name": "get_weather",
"result": "The weather in San Francisco is 68°F and sunny.",
"tool_id": "call_abc123",
"type": "function"
}
]
}
],
"model_id": "gpt-4o",
"openai_metadata": {
"reasoning_effort": "medium",
"reasoning_summary": "auto"
},
"presence_penalty": 0,
"temperature": 0.7,
"tools": [
{
"function": {
"description": "Get the current weather for a location.",
"name": "get_weather",
"parameters": {
"properties": {
"location": {
"type": "string"
}
},
"type": "object"
}
},
"type": "function"
}
],
"top_k": 50,
"top_p": 1,
"vertex_ai_metadata": {
"location": "us-central1",
"project": "my-gcp-project",
"project_ids": [
"my-gcp-project"
]
}
}응답
OK
The result of an LLM inference request, including input parameters and the model response.
anthropic_metadataAnthropic-specific metadata for an inference request.
effortThe effort level for Anthropic inference.
low, medium, high, maxthinkingConfiguration for Anthropic extended thinking feature.
budget_tokensMaximum token budget for extended thinking. Required when type is enabled.
type [required]The thinking mode for Anthropic extended thinking.
enabled, disabled, adaptiveazure_openai_metadataAzure OpenAI-specific metadata for an integration account or inference request.
deployment_idThe Azure OpenAI deployment ID.
model_versionThe model version deployed in Azure.
resource_nameThe Azure OpenAI resource name.
bedrock_metadataAmazon Bedrock-specific metadata for an inference request.
regionThe AWS region for the Bedrock request.
error_responseError details returned when an inference provider returns an error.
message [required]A human-readable description of the error.
type [required]The provider-specific error type.
frequency_penaltyFrequency penalty that was applied.
json_schemaJSON schema that was applied for structured output.
max_completion_tokensMaximum number of completion tokens that were configured.
max_tokensMaximum number of tokens that were configured.
messages [required]List of messages in an inference conversation.
contentPlain text content of the message.
contentsList of structured content blocks in a message.
type [required]The content block type.
value [required]The typed value of a message content block.
textPlain text content.
tool_callA tool call made during LLM inference.
argumentsThe arguments passed to the tool.
nameThe name of the tool being called.
tool_idUnique identifier for the tool call.
typeThe type of tool call.
tool_call_resultThe result returned by a tool call during LLM inference.
nameThe name of the tool that produced this result.
resultThe result content returned by the tool.
tool_idIdentifier matching the corresponding tool call.
typeThe type of tool result.
idUnique identifier for the message.
roleThe role of the message author.
tool_callsList of tool calls in a message.
argumentsThe arguments passed to the tool.
nameThe name of the tool being called.
tool_idUnique identifier for the tool call.
typeThe type of tool call.
tool_resultsList of tool results in a message.
nameThe name of the tool that produced this result.
resultThe result content returned by the tool.
tool_idIdentifier matching the corresponding tool call.
typeThe type of tool result.
model_id [required]The model identifier used for inference.
openai_metadataOpenAI-specific metadata for an inference request.
reasoning_effortThe reasoning effort level for OpenAI models that support it.
none, low, medium, high, xhighreasoning_summaryThe verbosity of the reasoning summary.
auto, concise, detailedpresence_penaltyPresence penalty that was applied.
response [required]The output of a completed LLM inference call.
assessment [required]An optional assessment of the inference output quality.
content [required]The text content of the model response.
finish_reason [required]The reason the model stopped generating tokens.
inference_codes [required]List of generated code snippets for the inference configuration.
code [required]The generated code content.
id [required]Unique identifier for the code snippet.
type [required]The programming language or SDK type of the code snippet.
input_tokens [required]Number of input tokens consumed.
internal_reasoningThe model's internal reasoning or thinking output, if available.
reasoning_tokensNumber of tokens used for internal reasoning.
text [required]The reasoning text produced by the model.
latency [required]Request latency in milliseconds.
output_tokens [required]Number of output tokens generated.
tools [required]List of tools available to the model.
function [required]A function definition for a tool available to the model.
descriptionA description of what the function does.
name [required]The name of the function.
parameters [required]JSON schema describing the function parameters.
type [required]The type of tool.
total_tokens [required]Total tokens used (input plus output).
temperatureSampling temperature that was used.
toolsList of tools available to the model.
function [required]A function definition for a tool available to the model.
descriptionA description of what the function does.
name [required]The name of the function.
parameters [required]JSON schema describing the function parameters.
type [required]The type of tool.
top_kTop-K sampling parameter that was used.
top_pNucleus sampling parameter that was used.
vertex_ai_metadataVertex AI-specific metadata for an integration account or inference request.
locationThe Vertex AI region.
projectThe Google Cloud project ID.
project_idsList of Google Cloud project IDs available to the service account.
{
"anthropic_metadata": {
"effort": "medium",
"thinking": {
"budget_tokens": 1024,
"type": "enabled"
}
},
"azure_openai_metadata": {
"deployment_id": "my-gpt4-deployment",
"model_version": "0613",
"resource_name": "my-azure-resource"
},
"bedrock_metadata": {
"region": "us-east-1"
},
"error_response": {
"message": "The model does not exist.",
"type": "invalid_request_error"
},
"frequency_penalty": 0,
"json_schema": "{\"type\":\"object\",\"properties\":{\"answer\":{\"type\":\"string\"}}}",
"max_completion_tokens": 1024,
"max_tokens": 1024,
"messages": [
{
"content": "What is the capital of France?",
"contents": [
{
"type": "text",
"value": {
"text": "Hello, how can I help you?",
"tool_call": {
"arguments": {
"location": "San Francisco"
},
"name": "get_weather",
"tool_id": "call_abc123",
"type": "function"
},
"tool_call_result": {
"name": "get_weather",
"result": "The weather in San Francisco is 68°F and sunny.",
"tool_id": "call_abc123",
"type": "function"
}
}
}
],
"id": "msg_001",
"role": "user",
"tool_calls": [
{
"arguments": {
"location": "San Francisco"
},
"name": "get_weather",
"tool_id": "call_abc123",
"type": "function"
}
],
"tool_results": [
{
"name": "get_weather",
"result": "The weather in San Francisco is 68°F and sunny.",
"tool_id": "call_abc123",
"type": "function"
}
]
}
],
"model_id": "gpt-4o",
"openai_metadata": {
"reasoning_effort": "medium",
"reasoning_summary": "auto"
},
"presence_penalty": 0,
"response": {
"assessment": "pass",
"content": "The capital of France is Paris.",
"finish_reason": "stop",
"inference_codes": [
{
"code": "import openai\nclient = openai.OpenAI()\n...",
"id": "code-python-001",
"type": "python"
}
],
"input_tokens": 15,
"internal_reasoning": {
"reasoning_tokens": 256,
"text": "Let me think about this step by step..."
},
"latency": 843,
"output_tokens": 10,
"tools": [
{
"function": {
"description": "Get the current weather for a location.",
"name": "get_weather",
"parameters": {
"properties": {
"location": {
"type": "string"
}
},
"type": "object"
}
},
"type": "function"
}
],
"total_tokens": 25
},
"temperature": 0.7,
"tools": [
{
"function": {
"description": "Get the current weather for a location.",
"name": "get_weather",
"parameters": {
"properties": {
"location": {
"type": "string"
}
},
"type": "object"
}
},
"type": "function"
}
],
"top_k": 50,
"top_p": 1,
"vertex_ai_metadata": {
"location": "us-central1",
"project": "my-gcp-project",
"project_ids": [
"my-gcp-project"
]
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Unauthorized
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Internal Server Error
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}코드 예시
# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF# Path parameters
export integration="openai"
export account_id="account-abc123"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/llm-obs/v1/integrations/${integration}/${account_id}/inference" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"max_tokens": 256,
"messages": [
{
"content": "What is the capital of France?",
"role": "user"
}
],
"model_id": "gpt-4o",
"temperature": 0.7
}
EOF// Run an LLM inference returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.LLMObsIntegrationInferenceRequest{
AnthropicMetadata: &datadogV2.LLMObsAnthropicMetadata{
Effort: *datadogV2.NewNullableLLMObsAnthropicEffort(datadogV2.LLMOBSANTHROPICEFFORT_MEDIUM.Ptr()),
Thinking: &datadogV2.LLMObsAnthropicThinkingConfig{
BudgetTokens: *datadog.NewNullableInt64(datadog.PtrInt64(1024)),
Type: datadogV2.LLMOBSANTHROPICTHINKINGTYPE_ENABLED,
},
},
AzureOpenaiMetadata: &datadogV2.LLMObsAzureOpenAIMetadata{
DeploymentId: datadog.PtrString("my-gpt4-deployment"),
ModelVersion: datadog.PtrString("0613"),
ResourceName: datadog.PtrString("my-azure-resource"),
},
BedrockMetadata: &datadogV2.LLMObsBedrockMetadata{
Region: datadog.PtrString("us-east-1"),
},
FrequencyPenalty: *datadog.NewNullableFloat64(datadog.PtrFloat64(0.0)),
JsonSchema: *datadog.NewNullableString(datadog.PtrString(`{"type":"object","properties":{"answer":{"type":"string"}}}`)),
MaxCompletionTokens: *datadog.NewNullableInt64(datadog.PtrInt64(1024)),
MaxTokens: *datadog.NewNullableInt64(datadog.PtrInt64(1024)),
Messages: []datadogV2.LLMObsInferenceMessage{
{
Content: datadog.PtrString("What is the capital of France?"),
Contents: []datadogV2.LLMObsInferenceContent{
{
Type: "text",
Value: datadogV2.LLMObsInferenceContentValue{
Text: datadog.PtrString("Hello, how can I help you?"),
ToolCall: &datadogV2.LLMObsInferenceToolCall{
Arguments: map[string]interface{}{
"location": "San Francisco",
},
Name: datadog.PtrString("get_weather"),
ToolId: datadog.PtrString("call_abc123"),
Type: datadog.PtrString("function"),
},
ToolCallResult: &datadogV2.LLMObsInferenceToolResult{
Name: datadog.PtrString("get_weather"),
Result: datadog.PtrString("The weather in San Francisco is 68°F and sunny."),
ToolId: datadog.PtrString("call_abc123"),
Type: datadog.PtrString("function"),
},
},
},
},
Id: datadog.PtrString("msg_001"),
Role: datadog.PtrString("user"),
ToolCalls: []datadogV2.LLMObsInferenceToolCall{
{
Arguments: map[string]interface{}{
"location": "San Francisco",
},
Name: datadog.PtrString("get_weather"),
ToolId: datadog.PtrString("call_abc123"),
Type: datadog.PtrString("function"),
},
},
ToolResults: []datadogV2.LLMObsInferenceToolResult{
{
Name: datadog.PtrString("get_weather"),
Result: datadog.PtrString("The weather in San Francisco is 68°F and sunny."),
ToolId: datadog.PtrString("call_abc123"),
Type: datadog.PtrString("function"),
},
},
},
},
ModelId: "gpt-4o",
OpenaiMetadata: &datadogV2.LLMObsOpenAIMetadata{
ReasoningEffort: *datadogV2.NewNullableLLMObsOpenAIReasoningEffort(datadogV2.LLMOBSOPENAIREASONINGEFFORT_MEDIUM.Ptr()),
ReasoningSummary: *datadogV2.NewNullableLLMObsOpenAIReasoningSummary(datadogV2.LLMOBSOPENAIREASONINGSUMMARY_AUTO.Ptr()),
},
PresencePenalty: *datadog.NewNullableFloat64(datadog.PtrFloat64(0.0)),
Temperature: *datadog.NewNullableFloat64(datadog.PtrFloat64(0.7)),
Tools: []datadogV2.LLMObsInferenceTool{
{
Function: datadogV2.LLMObsInferenceFunction{
Description: datadog.PtrString("Get the current weather for a location."),
Name: "get_weather",
Parameters: map[string]interface{}{
"properties": "{'location': {'type': 'string'}}",
"type": "object",
},
},
Type: "function",
},
},
TopK: *datadog.NewNullableInt64(datadog.PtrInt64(50)),
TopP: *datadog.NewNullableFloat64(datadog.PtrFloat64(1.0)),
VertexAiMetadata: &datadogV2.LLMObsVertexAIMetadata{
Location: datadog.PtrString("us-central1"),
Project: datadog.PtrString("my-gcp-project"),
ProjectIds: []string{
"my-gcp-project",
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateLLMObsIntegrationInference", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewAgentObservabilityApi(apiClient)
resp, r, err := api.CreateLLMObsIntegrationInference(ctx, datadogV2.LLMOBSINTEGRATIONNAME_OPENAI, "account_id", body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AgentObservabilityApi.CreateLLMObsIntegrationInference`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AgentObservabilityApi.CreateLLMObsIntegrationInference`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Run an LLM inference returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.AgentObservabilityApi;
import com.datadog.api.client.v2.model.LLMObsAnthropicEffort;
import com.datadog.api.client.v2.model.LLMObsAnthropicMetadata;
import com.datadog.api.client.v2.model.LLMObsAnthropicThinkingConfig;
import com.datadog.api.client.v2.model.LLMObsAnthropicThinkingType;
import com.datadog.api.client.v2.model.LLMObsAzureOpenAIMetadata;
import com.datadog.api.client.v2.model.LLMObsBedrockMetadata;
import com.datadog.api.client.v2.model.LLMObsInferenceContent;
import com.datadog.api.client.v2.model.LLMObsInferenceContentValue;
import com.datadog.api.client.v2.model.LLMObsInferenceFunction;
import com.datadog.api.client.v2.model.LLMObsInferenceMessage;
import com.datadog.api.client.v2.model.LLMObsInferenceTool;
import com.datadog.api.client.v2.model.LLMObsInferenceToolCall;
import com.datadog.api.client.v2.model.LLMObsInferenceToolResult;
import com.datadog.api.client.v2.model.LLMObsIntegrationInferenceRequest;
import com.datadog.api.client.v2.model.LLMObsIntegrationInferenceResponse;
import com.datadog.api.client.v2.model.LLMObsIntegrationName;
import com.datadog.api.client.v2.model.LLMObsOpenAIMetadata;
import com.datadog.api.client.v2.model.LLMObsOpenAIReasoningEffort;
import com.datadog.api.client.v2.model.LLMObsOpenAIReasoningSummary;
import com.datadog.api.client.v2.model.LLMObsVertexAIMetadata;
import java.util.Collections;
import java.util.Map;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createLLMObsIntegrationInference", true);
AgentObservabilityApi apiInstance = new AgentObservabilityApi(defaultClient);
LLMObsIntegrationInferenceRequest body =
new LLMObsIntegrationInferenceRequest()
.anthropicMetadata(
new LLMObsAnthropicMetadata()
.effort(LLMObsAnthropicEffort.MEDIUM)
.thinking(
new LLMObsAnthropicThinkingConfig()
.budgetTokens(1024L)
.type(LLMObsAnthropicThinkingType.ENABLED)))
.azureOpenaiMetadata(
new LLMObsAzureOpenAIMetadata()
.deploymentId("my-gpt4-deployment")
.modelVersion("0613")
.resourceName("my-azure-resource"))
.bedrockMetadata(new LLMObsBedrockMetadata().region("us-east-1"))
.jsonSchema("""
{"type":"object","properties":{"answer":{"type":"string"}}}
""")
.maxCompletionTokens(1024L)
.maxTokens(1024L)
.messages(
Collections.singletonList(
new LLMObsInferenceMessage()
.content("What is the capital of France?")
.contents(
Collections.singletonList(
new LLMObsInferenceContent()
.type("text")
.value(
new LLMObsInferenceContentValue()
.text("Hello, how can I help you?")
.toolCall(
new LLMObsInferenceToolCall()
.arguments(
Map.ofEntries(
Map.entry("location", "San Francisco")))
.name("get_weather")
.toolId("call_abc123")
.type("function"))
.toolCallResult(
new LLMObsInferenceToolResult()
.name("get_weather")
.result(
"The weather in San Francisco is 68°F and"
+ " sunny.")
.toolId("call_abc123")
.type("function")))))
.id("msg_001")
.role("user")
.toolCalls(
Collections.singletonList(
new LLMObsInferenceToolCall()
.arguments(
Map.ofEntries(Map.entry("location", "San Francisco")))
.name("get_weather")
.toolId("call_abc123")
.type("function")))
.toolResults(
Collections.singletonList(
new LLMObsInferenceToolResult()
.name("get_weather")
.result("The weather in San Francisco is 68°F and sunny.")
.toolId("call_abc123")
.type("function")))))
.modelId("gpt-4o")
.openaiMetadata(
new LLMObsOpenAIMetadata()
.reasoningEffort(LLMObsOpenAIReasoningEffort.MEDIUM)
.reasoningSummary(LLMObsOpenAIReasoningSummary.AUTO))
.temperature(0.7)
.tools(
Collections.singletonList(
new LLMObsInferenceTool()
.function(
new LLMObsInferenceFunction()
.description("Get the current weather for a location.")
.name("get_weather")
.parameters(
Map.ofEntries(
Map.entry("properties", "{'location': {'type': 'string'}}"),
Map.entry("type", "object"))))
.type("function")))
.topK(50L)
.topP(1.0)
.vertexAiMetadata(
new LLMObsVertexAIMetadata()
.location("us-central1")
.project("my-gcp-project")
.projectIds(Collections.singletonList("my-gcp-project")));
try {
LLMObsIntegrationInferenceResponse result =
apiInstance.createLLMObsIntegrationInference(
LLMObsIntegrationName.OPENAI, "account-abc123", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling AgentObservabilityApi#createLLMObsIntegrationInference");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Run an LLM inference returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.agent_observability_api import AgentObservabilityApi
from datadog_api_client.v2.model.llm_obs_anthropic_effort import LLMObsAnthropicEffort
from datadog_api_client.v2.model.llm_obs_anthropic_metadata import LLMObsAnthropicMetadata
from datadog_api_client.v2.model.llm_obs_anthropic_thinking_config import LLMObsAnthropicThinkingConfig
from datadog_api_client.v2.model.llm_obs_anthropic_thinking_type import LLMObsAnthropicThinkingType
from datadog_api_client.v2.model.llm_obs_azure_open_ai_metadata import LLMObsAzureOpenAIMetadata
from datadog_api_client.v2.model.llm_obs_bedrock_metadata import LLMObsBedrockMetadata
from datadog_api_client.v2.model.llm_obs_inference_content import LLMObsInferenceContent
from datadog_api_client.v2.model.llm_obs_inference_content_value import LLMObsInferenceContentValue
from datadog_api_client.v2.model.llm_obs_inference_function import LLMObsInferenceFunction
from datadog_api_client.v2.model.llm_obs_inference_message import LLMObsInferenceMessage
from datadog_api_client.v2.model.llm_obs_inference_tool import LLMObsInferenceTool
from datadog_api_client.v2.model.llm_obs_inference_tool_call import LLMObsInferenceToolCall
from datadog_api_client.v2.model.llm_obs_inference_tool_result import LLMObsInferenceToolResult
from datadog_api_client.v2.model.llm_obs_integration_inference_request import LLMObsIntegrationInferenceRequest
from datadog_api_client.v2.model.llm_obs_integration_name import LLMObsIntegrationName
from datadog_api_client.v2.model.llm_obs_open_ai_metadata import LLMObsOpenAIMetadata
from datadog_api_client.v2.model.llm_obs_open_ai_reasoning_effort import LLMObsOpenAIReasoningEffort
from datadog_api_client.v2.model.llm_obs_open_ai_reasoning_summary import LLMObsOpenAIReasoningSummary
from datadog_api_client.v2.model.llm_obs_vertex_ai_metadata import LLMObsVertexAIMetadata
body = LLMObsIntegrationInferenceRequest(
anthropic_metadata=LLMObsAnthropicMetadata(
effort=LLMObsAnthropicEffort.MEDIUM,
thinking=LLMObsAnthropicThinkingConfig(
budget_tokens=1024,
type=LLMObsAnthropicThinkingType.ENABLED,
),
),
azure_openai_metadata=LLMObsAzureOpenAIMetadata(
deployment_id="my-gpt4-deployment",
model_version="0613",
resource_name="my-azure-resource",
),
bedrock_metadata=LLMObsBedrockMetadata(
region="us-east-1",
),
frequency_penalty=0.0,
json_schema='{"type":"object","properties":{"answer":{"type":"string"}}}',
max_completion_tokens=1024,
max_tokens=1024,
messages=[
LLMObsInferenceMessage(
content="What is the capital of France?",
contents=[
LLMObsInferenceContent(
type="text",
value=LLMObsInferenceContentValue(
text="Hello, how can I help you?",
tool_call=LLMObsInferenceToolCall(
arguments=dict([("location", "San Francisco")]),
name="get_weather",
tool_id="call_abc123",
type="function",
),
tool_call_result=LLMObsInferenceToolResult(
name="get_weather",
result="The weather in San Francisco is 68°F and sunny.",
tool_id="call_abc123",
type="function",
),
),
),
],
id="msg_001",
role="user",
tool_calls=[
LLMObsInferenceToolCall(
arguments=dict([("location", "San Francisco")]),
name="get_weather",
tool_id="call_abc123",
type="function",
),
],
tool_results=[
LLMObsInferenceToolResult(
name="get_weather",
result="The weather in San Francisco is 68°F and sunny.",
tool_id="call_abc123",
type="function",
),
],
),
],
model_id="gpt-4o",
openai_metadata=LLMObsOpenAIMetadata(
reasoning_effort=LLMObsOpenAIReasoningEffort.MEDIUM,
reasoning_summary=LLMObsOpenAIReasoningSummary.AUTO,
),
presence_penalty=0.0,
temperature=0.7,
tools=[
LLMObsInferenceTool(
function=LLMObsInferenceFunction(
description="Get the current weather for a location.",
name="get_weather",
parameters=dict([("properties", "{'location': {'type': 'string'}}"), ("type", "object")]),
),
type="function",
),
],
top_k=50,
top_p=1.0,
vertex_ai_metadata=LLMObsVertexAIMetadata(
location="us-central1",
project="my-gcp-project",
project_ids=[
"my-gcp-project",
],
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_llm_obs_integration_inference"] = True
with ApiClient(configuration) as api_client:
api_instance = AgentObservabilityApi(api_client)
response = api_instance.create_llm_obs_integration_inference(
integration=LLMObsIntegrationName.OPENAI, account_id="account_id", body=body
)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Run an LLM inference returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_llm_obs_integration_inference".to_sym] = true
end
api_instance = DatadogAPIClient::V2::AgentObservabilityAPI.new
body = DatadogAPIClient::V2::LLMObsIntegrationInferenceRequest.new({
anthropic_metadata: DatadogAPIClient::V2::LLMObsAnthropicMetadata.new({
effort: DatadogAPIClient::V2::LLMObsAnthropicEffort::MEDIUM,
thinking: DatadogAPIClient::V2::LLMObsAnthropicThinkingConfig.new({
budget_tokens: 1024,
type: DatadogAPIClient::V2::LLMObsAnthropicThinkingType::ENABLED,
}),
}),
azure_openai_metadata: DatadogAPIClient::V2::LLMObsAzureOpenAIMetadata.new({
deployment_id: "my-gpt4-deployment",
model_version: "0613",
resource_name: "my-azure-resource",
}),
bedrock_metadata: DatadogAPIClient::V2::LLMObsBedrockMetadata.new({
region: "us-east-1",
}),
frequency_penalty: 0.0,
json_schema: '{"type":"object","properties":{"answer":{"type":"string"}}}',
max_completion_tokens: 1024,
max_tokens: 1024,
messages: [
DatadogAPIClient::V2::LLMObsInferenceMessage.new({
content: "What is the capital of France?",
contents: [
DatadogAPIClient::V2::LLMObsInferenceContent.new({
type: "text",
value: DatadogAPIClient::V2::LLMObsInferenceContentValue.new({
text: "Hello, how can I help you?",
tool_call: DatadogAPIClient::V2::LLMObsInferenceToolCall.new({
arguments: {
"location": "San Francisco",
},
name: "get_weather",
tool_id: "call_abc123",
type: "function",
}),
tool_call_result: DatadogAPIClient::V2::LLMObsInferenceToolResult.new({
name: "get_weather",
result: "The weather in San Francisco is 68°F and sunny.",
tool_id: "call_abc123",
type: "function",
}),
}),
}),
],
id: "msg_001",
role: "user",
tool_calls: [
DatadogAPIClient::V2::LLMObsInferenceToolCall.new({
arguments: {
"location": "San Francisco",
},
name: "get_weather",
tool_id: "call_abc123",
type: "function",
}),
],
tool_results: [
DatadogAPIClient::V2::LLMObsInferenceToolResult.new({
name: "get_weather",
result: "The weather in San Francisco is 68°F and sunny.",
tool_id: "call_abc123",
type: "function",
}),
],
}),
],
model_id: "gpt-4o",
openai_metadata: DatadogAPIClient::V2::LLMObsOpenAIMetadata.new({
reasoning_effort: DatadogAPIClient::V2::LLMObsOpenAIReasoningEffort::MEDIUM,
reasoning_summary: DatadogAPIClient::V2::LLMObsOpenAIReasoningSummary::AUTO,
}),
presence_penalty: 0.0,
temperature: 0.7,
tools: [
DatadogAPIClient::V2::LLMObsInferenceTool.new({
function: DatadogAPIClient::V2::LLMObsInferenceFunction.new({
description: "Get the current weather for a location.",
name: "get_weather",
parameters: {
"properties": "{'location': {'type': 'string'}}", "type": "object",
},
}),
type: "function",
}),
],
top_k: 50,
top_p: 1.0,
vertex_ai_metadata: DatadogAPIClient::V2::LLMObsVertexAIMetadata.new({
location: "us-central1",
project: "my-gcp-project",
project_ids: [
"my-gcp-project",
],
}),
})
p api_instance.create_llm_obs_integration_inference(LLMObsIntegrationName::OPENAI, "account_id", body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Run an LLM inference returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_agent_observability::AgentObservabilityAPI;
use datadog_api_client::datadogV2::model::LLMObsAnthropicEffort;
use datadog_api_client::datadogV2::model::LLMObsAnthropicMetadata;
use datadog_api_client::datadogV2::model::LLMObsAnthropicThinkingConfig;
use datadog_api_client::datadogV2::model::LLMObsAnthropicThinkingType;
use datadog_api_client::datadogV2::model::LLMObsAzureOpenAIMetadata;
use datadog_api_client::datadogV2::model::LLMObsBedrockMetadata;
use datadog_api_client::datadogV2::model::LLMObsInferenceContent;
use datadog_api_client::datadogV2::model::LLMObsInferenceContentValue;
use datadog_api_client::datadogV2::model::LLMObsInferenceFunction;
use datadog_api_client::datadogV2::model::LLMObsInferenceMessage;
use datadog_api_client::datadogV2::model::LLMObsInferenceTool;
use datadog_api_client::datadogV2::model::LLMObsInferenceToolCall;
use datadog_api_client::datadogV2::model::LLMObsInferenceToolResult;
use datadog_api_client::datadogV2::model::LLMObsIntegrationInferenceRequest;
use datadog_api_client::datadogV2::model::LLMObsIntegrationName;
use datadog_api_client::datadogV2::model::LLMObsOpenAIMetadata;
use datadog_api_client::datadogV2::model::LLMObsOpenAIReasoningEffort;
use datadog_api_client::datadogV2::model::LLMObsOpenAIReasoningSummary;
use datadog_api_client::datadogV2::model::LLMObsVertexAIMetadata;
use serde_json::Value;
use std::collections::BTreeMap;
#[tokio::main]
async fn main() {
let body = LLMObsIntegrationInferenceRequest::new(
vec![LLMObsInferenceMessage::new()
.content("What is the capital of France?".to_string())
.contents(vec![LLMObsInferenceContent::new(
"text".to_string(),
LLMObsInferenceContentValue::new()
.text("Hello, how can I help you?".to_string())
.tool_call(
LLMObsInferenceToolCall::new()
.arguments(BTreeMap::from([(
"location".to_string(),
Value::from("San Francisco"),
)]))
.name("get_weather".to_string())
.tool_id("call_abc123".to_string())
.type_("function".to_string()),
)
.tool_call_result(
LLMObsInferenceToolResult::new()
.name("get_weather".to_string())
.result("The weather in San Francisco is 68°F and sunny.".to_string())
.tool_id("call_abc123".to_string())
.type_("function".to_string()),
),
)])
.id("msg_001".to_string())
.role("user".to_string())
.tool_calls(vec![LLMObsInferenceToolCall::new()
.arguments(BTreeMap::from([(
"location".to_string(),
Value::from("San Francisco"),
)]))
.name("get_weather".to_string())
.tool_id("call_abc123".to_string())
.type_("function".to_string())])
.tool_results(vec![LLMObsInferenceToolResult::new()
.name("get_weather".to_string())
.result("The weather in San Francisco is 68°F and sunny.".to_string())
.tool_id("call_abc123".to_string())
.type_("function".to_string())])],
"gpt-4o".to_string(),
)
.anthropic_metadata(
LLMObsAnthropicMetadata::new()
.effort(Some(LLMObsAnthropicEffort::MEDIUM))
.thinking(
LLMObsAnthropicThinkingConfig::new(LLMObsAnthropicThinkingType::ENABLED)
.budget_tokens(Some(1024)),
),
)
.azure_openai_metadata(
LLMObsAzureOpenAIMetadata::new()
.deployment_id("my-gpt4-deployment".to_string())
.model_version("0613".to_string())
.resource_name("my-azure-resource".to_string()),
)
.bedrock_metadata(LLMObsBedrockMetadata::new().region("us-east-1".to_string()))
.frequency_penalty(Some(0.0 as f64))
.json_schema(Some(
r#"{"type":"object","properties":{"answer":{"type":"string"}}}"#.to_string(),
))
.max_completion_tokens(Some(1024))
.max_tokens(Some(1024))
.openai_metadata(
LLMObsOpenAIMetadata::new()
.reasoning_effort(Some(LLMObsOpenAIReasoningEffort::MEDIUM))
.reasoning_summary(Some(LLMObsOpenAIReasoningSummary::AUTO)),
)
.presence_penalty(Some(0.0 as f64))
.temperature(Some(0.7 as f64))
.tools(vec![LLMObsInferenceTool::new(
LLMObsInferenceFunction::new(
"get_weather".to_string(),
BTreeMap::from([("type".to_string(), Value::from("object"))]),
)
.description("Get the current weather for a location.".to_string()),
"function".to_string(),
)])
.top_k(Some(50))
.top_p(Some(1.0 as f64))
.vertex_ai_metadata(
LLMObsVertexAIMetadata::new()
.location("us-central1".to_string())
.project("my-gcp-project".to_string())
.project_ids(vec!["my-gcp-project".to_string()]),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_llm_obs_integration_inference", true);
let api = AgentObservabilityAPI::with_config(configuration);
let resp = api
.create_llm_obs_integration_inference(
LLMObsIntegrationName::OPENAI,
"account_id".to_string(),
body,
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Run an LLM inference returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.createLLMObsIntegrationInference"] = true;
const apiInstance = new v2.AgentObservabilityApi(configuration);
const params: v2.AgentObservabilityApiCreateLLMObsIntegrationInferenceRequest =
{
body: {
anthropicMetadata: {
effort: "medium",
thinking: {
budgetTokens: 1024,
type: "enabled",
},
},
azureOpenaiMetadata: {
deploymentId: "my-gpt4-deployment",
modelVersion: "0613",
resourceName: "my-azure-resource",
},
bedrockMetadata: {
region: "us-east-1",
},
frequencyPenalty: 0.0,
jsonSchema: `{"type":"object","properties":{"answer":{"type":"string"}}}`,
maxCompletionTokens: 1024,
maxTokens: 1024,
messages: [
{
content: "What is the capital of France?",
contents: [
{
type: "text",
value: {
text: "Hello, how can I help you?",
toolCall: {
arguments: {
location: "San Francisco",
},
name: "get_weather",
toolId: "call_abc123",
type: "function",
},
toolCallResult: {
name: "get_weather",
result: "The weather in San Francisco is 68°F and sunny.",
toolId: "call_abc123",
type: "function",
},
},
},
],
id: "msg_001",
role: "user",
toolCalls: [
{
arguments: {
location: "San Francisco",
},
name: "get_weather",
toolId: "call_abc123",
type: "function",
},
],
toolResults: [
{
name: "get_weather",
result: "The weather in San Francisco is 68°F and sunny.",
toolId: "call_abc123",
type: "function",
},
],
},
],
modelId: "gpt-4o",
openaiMetadata: {
reasoningEffort: "medium",
reasoningSummary: "auto",
},
presencePenalty: 0.0,
temperature: 0.7,
tools: [
{
_function: {
description: "Get the current weather for a location.",
name: "get_weather",
parameters: {
properties: "{'location': {'type': 'string'}}",
type: "object",
},
},
type: "function",
},
],
topK: 50,
topP: 1.0,
vertexAiMetadata: {
location: "us-central1",
project: "my-gcp-project",
projectIds: ["my-gcp-project"],
},
},
integration: "openai",
accountId: "account_id",
};
apiInstance
.createLLMObsIntegrationInference(params)
.then((data: v2.LLMObsIntegrationInferenceResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"