messages Module

OTEL gen-ai semantic convention message types.

Defines the structured message format for input/output message tracing, following the OpenTelemetry gen-ai semantic conventions: https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json

Classes

BlobPart

Inline binary data (base64-encoded).

ChatMessage

An input message sent to a model (OTEL gen-ai semantic conventions).

FilePart

Reference to a pre-uploaded file.

GenericPart

Extensible part for custom / future types.

InputMessages

Container for input messages. Serializes as a plain JSON array per OTel spec.

OutputMessage

An output message produced by a model (OTEL gen-ai semantic conventions).

finish_reason defaults to "stop" per OTel spec when not provided.

OutputMessages

Container for output messages. Serializes as a plain JSON array per OTel spec.

ReasoningPart

Model reasoning / chain-of-thought content.

ServerToolCallPart

Server-side tool invocation.

ServerToolCallResponsePart

Server-side tool response.

TextPart

Plain text content.

ToolCallRequestPart

A tool call requested by the model.

ToolCallResponsePart

Result of a tool call.

UriPart

External URI reference.

Enums

FinishReason

Reason a model stopped generating per OTEL gen-ai semantic conventions.

MessageRole

Role of a message participant per OTEL gen-ai semantic conventions.

Modality

Media modality for blob, file, and URI parts.

Data

InputMessagesParam

Accepted input for record_input_messages.

Supports a single string, a list of strings (backward compat), or the structured container.

alias of Union[str, list[str], InputMessages]

InputMessagesParam

MessagePart

Union of all message part types per OTEL gen-ai semantic conventions.

alias of Union[TextPart, ToolCallRequestPart, ToolCallResponsePart, ReasoningPart, BlobPart, FilePart, UriPart, ServerToolCallPart, ServerToolCallResponsePart, GenericPart]

MessagePart

OutputMessagesParam

Accepted input for record_output_messages.

Supports a single string, a list of strings (backward compat), or the structured container.

alias of Union[str, list[str], OutputMessages]

OutputMessagesParam