Skip to main content Link Search Menu Expand Document (external link)

OpenAiTelemetry.ts overview

Since v1.0.0


Exports Grouped by Category


models

OpenAiTelemetryAttributes (type alias)

The attributes used to describe telemetry in the context of Generative Artificial Intelligence (GenAI) Models requests and responses.

{@see https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/}

Signature

type OpenAiTelemetryAttributes = Simplify<
  AiTelemetry.GenAITelemetryAttributes &
    AiTelemetry.GenAI.AttributesWithPrefix<OpenAiTelemetry.RequestAttributes, "gen_ai.openai.request"> &
    AiTelemetry.GenAI.AttributesWithPrefix<OpenAiTelemetry.ResponseAttributes, "gen_ai.openai.request">
>

Source

Since v1.0.0

utils

OpenAiTelemetry (namespace)

Source

Since v1.0.0

RequestAttributes (interface)

Telemetry attributes which are part of the GenAI specification and are namespaced by gen_ai.openai.request.

Signature

export interface RequestAttributes {
  /**
   * The response format that is requested.
   */
  readonly responseFormat?: (string & {}) | WellKnownResponseFormat | null | undefined
  /**
   * The service tier requested. May be a specific tier, `default`, or `auto`.
   */
  readonly serviceTier?: (string & {}) | WellKnownServiceTier | null | undefined
}

Source

Since v1.0.0

ResponseAttributes (interface)

Telemetry attributes which are part of the GenAI specification and are namespaced by gen_ai.openai.response.

Signature

export interface ResponseAttributes {
  /**
   * The service tier used for the response.
   */
  readonly serviceTier?: string | null | undefined
  /**
   * A fingerprint to track any eventual change in the Generative AI
   * environment.
   */
  readonly systemFingerprint?: string | null | undefined
}

Source

Since v1.0.0

AllAttributes (type alias)

All telemetry attributes which are part of the GenAI specification, including the OpenAi-specific attributes.

Signature

type AllAttributes = AiTelemetry.GenAI.AllAttributes & RequestAttributes & ResponseAttributes

Source

Since v1.0.0

WellKnownResponseFormat (type alias)

The gen_ai.openai.request.response_format attribute has the following list of well-known values.

If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

Signature

type WellKnownResponseFormat = "json_object" | "json_schema" | "text"

Source

Since v1.0.0

WellKnownServiceTier (type alias)

The gen_ai.openai.request.service_tier attribute has the following list of well-known values.

If one of them applies, then the respective value MUST be used; otherwise, a custom value MAY be used.

Signature

type WellKnownServiceTier = "auto" | "default"

Source

Since v1.0.0

OpenAiTelemetryAttributeOptions (type alias)

Signature

type OpenAiTelemetryAttributeOptions = AiTelemetry.GenAITelemetryAttributeOptions & {
  openai?:
    | {
        request?: OpenAiTelemetry.RequestAttributes | undefined
        response?: OpenAiTelemetry.ResponseAttributes | undefined
      }
    | undefined
}

Source

Since v1.0.0, models

addGenAIAnnotations

Applies the specified OpenAi GenAI telemetry attributes to the provided Span.

NOTE: This method will mutate the Span in-place.

Signature

declare const addGenAIAnnotations: any

Source

Since v1.0.0, utilities