Skip to main content

OpenTelemetry GenAI Utils

Project description

This package plugs the deepeval metrics suite into the OpenTelemetry GenAI evaluation pipeline. When it is installed a Deepeval evaluator is registered automatically and, unless explicitly disabled, is executed for every LLM/agent invocation alongside the builtin metrics.

Installation

Install the evaluator (and its runtime dependencies) from PyPI:

pip install opentelemetry-util-genai-evals-deepeval

The command pulls in opentelemetry-util-genai, deepeval and openai automatically so the evaluator is ready to use right after installation.

Requirements

  • opentelemetry-util-genai together with deepeval and openai – these are installed automatically when you install this package.

  • An LLM provider supported by Deepeval. By default the evaluator uses OpenAI’s gpt-4o-mini model because it offers the best balance of latency and cost for judge workloads right now, so make sure OPENAI_API_KEY is available. To override the model, set DEEPEVAL_EVALUATION_MODEL (or DEEPEVAL_MODEL / OPENAI_MODEL) to a different deployment along with the corresponding provider credentials.

  • (Optional) DEEPEVAL_API_KEY if your Deepeval account requires it.

Configuration

Use OTEL_INSTRUMENTATION_GENAI_EVALS_EVALUATORS to select the metrics that should run. Leaving the variable unset enables every registered evaluator with its default metric set. Examples:

  • OTEL_INSTRUMENTATION_GENAI_EVALS_EVALUATORS=Deepeval – run the default Deepeval bundle (Bias, Toxicity, Answer Relevancy, Faithfulness).

  • OTEL_INSTRUMENTATION_GENAI_EVALS_EVALUATORS=Deepeval(LLMInvocation(bias(threshold=0.75))) – override the Bias threshold for LLM invocations and skip the remaining metrics.

  • OTEL_INSTRUMENTATION_GENAI_EVALS_EVALUATORS=none – disable the evaluator entirely.

Results are emitted through the standard GenAI evaluation emitters (events, metrics, spans). Each metric includes helper attributes such as deepeval.success, deepeval.threshold and any evaluation model metadata returned by Deepeval. Metrics that cannot run because required inputs are missing (for example Faithfulness without a retrieval_context) are marked as label="skipped" and carry a deepeval.error attribute so you can wire the necessary data or disable that metric explicitly.

Default OpenAI Usage

If you’re using OpenAI directly, no additional configuration is needed. Simply set OPENAI_API_KEY and the evaluator will work out of the box:

export OPENAI_API_KEY="sk-your-openai-api-key"

The custom DEEPEVAL_LLM_* environment variables described below are only needed when using a custom LLM provider (e.g., Azure OpenAI, private deployments, or API gateways). They do not affect the default OpenAI behavior.

Custom LLM Provider Configuration

Use these environment variables to configure a custom LLM endpoint (e.g., Azure OpenAI, private deployments, or LLM gateways). These settings are optional and only apply when DEEPEVAL_LLM_BASE_URL is set:

Basic Configuration:

Environment Variable

Description

DEEPEVAL_LLM_BASE_URL

Custom LLM endpoint URL (required for custom providers)

DEEPEVAL_LLM_MODEL

Model name (default: gpt-4o-mini)

DEEPEVAL_LLM_PROVIDER

Provider identifier for model prefix (default: openai)

DEEPEVAL_LLM_API_KEY

Static API key (use this OR OAuth2, not both)

DEEPEVAL_LLM_AUTH_HEADER

Auth header name (default: api-key)

DEEPEVAL_LLM_EXTRA_HEADERS

JSON string of additional HTTP headers (see examples below)

DEEPEVAL_LLM_CLIENT_APP_NAME

App key/name passed in request body for some providers

OAuth2 Authentication

For providers requiring OAuth2 token-based authentication:

Environment Variable

Description

DEEPEVAL_LLM_TOKEN_URL

OAuth2 token endpoint (enables OAuth2 mode)

DEEPEVAL_LLM_CLIENT_ID

OAuth2 client ID

DEEPEVAL_LLM_CLIENT_SECRET

OAuth2 client secret

DEEPEVAL_LLM_GRANT_TYPE

OAuth2 grant type (default: client_credentials)

DEEPEVAL_LLM_SCOPE

OAuth2 scope (optional)

DEEPEVAL_LLM_AUTH_METHOD

Token auth method: basic (default) or post

Examples

Static API Key (Azure OpenAI):

export DEEPEVAL_LLM_BASE_URL="https://your-resource.openai.azure.com/openai/deployments"
export DEEPEVAL_LLM_MODEL="gpt-4o"
export DEEPEVAL_LLM_PROVIDER="azure"
export DEEPEVAL_LLM_API_KEY="your-api-key"

OAuth2 with Basic Auth (Okta-style):

export DEEPEVAL_LLM_BASE_URL="https://llm-gateway.example.com/openai/deployments/gpt-4o-mini"
export DEEPEVAL_LLM_MODEL="gpt-4o-mini"
export DEEPEVAL_LLM_CLIENT_ID="your-client-id"
export DEEPEVAL_LLM_CLIENT_SECRET="your-client-secret"
export DEEPEVAL_LLM_TOKEN_URL="https://identity.example.com/oauth2/default/v1/token"
export DEEPEVAL_LLM_CLIENT_APP_NAME="your-app-key"

OAuth2 with Azure Active Directory:

export DEEPEVAL_LLM_BASE_URL="https://your-api.example.com/v1"
export DEEPEVAL_LLM_MODEL="gpt-4o"
export DEEPEVAL_LLM_PROVIDER="openai"
export DEEPEVAL_LLM_CLIENT_ID="azure-client-id"
export DEEPEVAL_LLM_CLIENT_SECRET="azure-client-secret"
export DEEPEVAL_LLM_TOKEN_URL="https://login.microsoftonline.com/tenant-id/oauth2/v2.0/token"
export DEEPEVAL_LLM_SCOPE="api://resource/.default"
export DEEPEVAL_LLM_AUTH_METHOD="post"

Custom Headers (for API gateways requiring additional headers):

# Add custom headers as JSON
export DEEPEVAL_LLM_EXTRA_HEADERS='{"system-code": "APP-123", "x-tenant-id": "tenant-abc"}'

# Combined with other settings
export DEEPEVAL_LLM_BASE_URL="https://gateway.example.com/openai/deployments"
export DEEPEVAL_LLM_MODEL="gpt-4o"
export DEEPEVAL_LLM_API_KEY="your-api-key"
export DEEPEVAL_LLM_EXTRA_HEADERS='{"system-code": "MYAPP-001"}'

The DEEPEVAL_LLM_EXTRA_HEADERS environment variable accepts a JSON-formatted string containing key-value pairs that will be added as HTTP headers to all LLM API requests. This is useful for API gateways that require custom headers for authentication or tracking.

Note: LiteLLM does not natively support setting extra_headers via environment variables (it must be passed programmatically). We provide DEEPEVAL_LLM_EXTRA_HEADERS to bridge this gap for DeepEval users who need custom headers without code changes. See LiteLLM SDK Header Support for more details on how headers work in LiteLLM.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

splunk_otel_genai_evals_deepeval-0.1.8.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file splunk_otel_genai_evals_deepeval-0.1.8.tar.gz.

File metadata

File hashes

Hashes for splunk_otel_genai_evals_deepeval-0.1.8.tar.gz
Algorithm Hash digest
SHA256 00d959b7f37096cdd9abd309ea1abfc811d65c0e5bb0217216db6f2553064e56
MD5 06892548c0bf9c1b8b74f1cbf81e4572
BLAKE2b-256 96b8c45b747f83fa4ce46f05958dc8cdcb953b150d0275d5fd719eb7099b2a31

See more details on using hashes here.

File details

Details for the file splunk_otel_genai_evals_deepeval-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for splunk_otel_genai_evals_deepeval-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ef008e88865dcf26a88cf4d6d090fa8e9a6e48239070ed177f131f9b077987e6
MD5 1dcc75ac01cf8dd3b1316e0951a434f0
BLAKE2b-256 de26a0ae26ffc1440efceedd5c9e0919209c418e38772fe7f42159cdbc82d97c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page