Skip to content

OpenAiTelemetry

8 exports Added in v1.0.0 Source

Models

AllAttributes type

Added in v1.0.0 Source

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

Signature

type AllAttributes = Telemetry.AllAttributes & RequestAttributes & ResponseAttributes;

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

https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/

Signature

type OpenAiTelemetryAttributes = Simplify<
  Telemetry.GenAITelemetryAttributes &
    Telemetry.AttributesWithPrefix<RequestAttributes, "gen_ai.openai.request"> &
    Telemetry.AttributesWithPrefix<ResponseAttributes, "gen_ai.openai.request">
>;

RequestAttributes interface

Added in v1.0.0 Source

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

Signature

interface RequestAttributes {
  readonly responseFormat?: (string & {}) | WellKnownResponseFormat | null;
  readonly serviceTier?: (string & {}) | WellKnownServiceTier | null;
}

ResponseAttributes interface

Added in v1.0.0 Source

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

Signature

interface ResponseAttributes {
  readonly serviceTier?: string | null;
  readonly systemFingerprint?: string | null;
}

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";

WellKnownServiceTier type

Added in v1.0.0 Source

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";

Other

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

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

Signature

declare const addGenAIAnnotations: (options: any) => (span: Span) => void & (span: Span, options: any) => void

Signature

type OpenAiTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & {
  openai?: {
    request?: RequestAttributes;
    response?: ResponseAttributes;
  };
};