Skip to content

Items

RealtimeMessageItem module-attribute

RealtimeMessageItem = Annotated[
    Union[
        SystemMessageItem,
        UserMessageItem,
        AssistantMessageItem,
    ],
    Field(discriminator="role"),
]

A message item that can be from system, user, or assistant.

RealtimeItem module-attribute

RealtimeItem = Union[
    RealtimeMessageItem, RealtimeToolCallItem
]

A realtime item that can be a message or tool call.

InputText

Bases: BaseModel

Text input content for realtime messages.

Source code in src/agents/realtime/items.py
class InputText(BaseModel):
    """Text input content for realtime messages."""

    type: Literal["input_text"] = "input_text"
    """The type identifier for text input."""

    text: str | None = None
    """The text content."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

type class-attribute instance-attribute

type: Literal['input_text'] = 'input_text'

The type identifier for text input.

text class-attribute instance-attribute

text: str | None = None

The text content.

InputAudio

Bases: BaseModel

Audio input content for realtime messages.

Source code in src/agents/realtime/items.py
class InputAudio(BaseModel):
    """Audio input content for realtime messages."""

    type: Literal["input_audio"] = "input_audio"
    """The type identifier for audio input."""

    audio: str | None = None
    """The base64-encoded audio data."""

    transcript: str | None = None
    """The transcript of the audio, if available."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

type class-attribute instance-attribute

type: Literal['input_audio'] = 'input_audio'

The type identifier for audio input.

audio class-attribute instance-attribute

audio: str | None = None

The base64-encoded audio data.

transcript class-attribute instance-attribute

transcript: str | None = None

The transcript of the audio, if available.

AssistantText

Bases: BaseModel

Text content from the assistant in realtime responses.

Source code in src/agents/realtime/items.py
class AssistantText(BaseModel):
    """Text content from the assistant in realtime responses."""

    type: Literal["text"] = "text"
    """The type identifier for text content."""

    text: str | None = None
    """The text content from the assistant."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

type class-attribute instance-attribute

type: Literal['text'] = 'text'

The type identifier for text content.

text class-attribute instance-attribute

text: str | None = None

The text content from the assistant.

AssistantAudio

Bases: BaseModel

Audio content from the assistant in realtime responses.

Source code in src/agents/realtime/items.py
class AssistantAudio(BaseModel):
    """Audio content from the assistant in realtime responses."""

    type: Literal["audio"] = "audio"
    """The type identifier for audio content."""

    audio: str | None = None
    """The base64-encoded audio data from the assistant."""

    transcript: str | None = None
    """The transcript of the audio response."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

type class-attribute instance-attribute

type: Literal['audio'] = 'audio'

The type identifier for audio content.

audio class-attribute instance-attribute

audio: str | None = None

The base64-encoded audio data from the assistant.

transcript class-attribute instance-attribute

transcript: str | None = None

The transcript of the audio response.

SystemMessageItem

Bases: BaseModel

A system message item in realtime conversations.

Source code in src/agents/realtime/items.py
class SystemMessageItem(BaseModel):
    """A system message item in realtime conversations."""

    item_id: str
    """Unique identifier for this message item."""

    previous_item_id: str | None = None
    """ID of the previous item in the conversation."""

    type: Literal["message"] = "message"
    """The type identifier for message items."""

    role: Literal["system"] = "system"
    """The role identifier for system messages."""

    content: list[InputText]
    """List of text content for the system message."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

item_id instance-attribute

item_id: str

Unique identifier for this message item.

previous_item_id class-attribute instance-attribute

previous_item_id: str | None = None

ID of the previous item in the conversation.

type class-attribute instance-attribute

type: Literal['message'] = 'message'

The type identifier for message items.

role class-attribute instance-attribute

role: Literal['system'] = 'system'

The role identifier for system messages.

content instance-attribute

content: list[InputText]

List of text content for the system message.

UserMessageItem

Bases: BaseModel

A user message item in realtime conversations.

Source code in src/agents/realtime/items.py
class UserMessageItem(BaseModel):
    """A user message item in realtime conversations."""

    item_id: str
    """Unique identifier for this message item."""

    previous_item_id: str | None = None
    """ID of the previous item in the conversation."""

    type: Literal["message"] = "message"
    """The type identifier for message items."""

    role: Literal["user"] = "user"
    """The role identifier for user messages."""

    content: list[Annotated[InputText | InputAudio, Field(discriminator="type")]]
    """List of content items, can be text or audio."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

item_id instance-attribute

item_id: str

Unique identifier for this message item.

previous_item_id class-attribute instance-attribute

previous_item_id: str | None = None

ID of the previous item in the conversation.

type class-attribute instance-attribute

type: Literal['message'] = 'message'

The type identifier for message items.

role class-attribute instance-attribute

role: Literal['user'] = 'user'

The role identifier for user messages.

content instance-attribute

content: list[
    Annotated[
        InputText | InputAudio, Field(discriminator="type")
    ]
]

List of content items, can be text or audio.

AssistantMessageItem

Bases: BaseModel

An assistant message item in realtime conversations.

Source code in src/agents/realtime/items.py
class AssistantMessageItem(BaseModel):
    """An assistant message item in realtime conversations."""

    item_id: str
    """Unique identifier for this message item."""

    previous_item_id: str | None = None
    """ID of the previous item in the conversation."""

    type: Literal["message"] = "message"
    """The type identifier for message items."""

    role: Literal["assistant"] = "assistant"
    """The role identifier for assistant messages."""

    status: Literal["in_progress", "completed", "incomplete"] | None = None
    """The status of the assistant's response."""

    content: list[Annotated[AssistantText | AssistantAudio, Field(discriminator="type")]]
    """List of content items from the assistant, can be text or audio."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

item_id instance-attribute

item_id: str

Unique identifier for this message item.

previous_item_id class-attribute instance-attribute

previous_item_id: str | None = None

ID of the previous item in the conversation.

type class-attribute instance-attribute

type: Literal['message'] = 'message'

The type identifier for message items.

role class-attribute instance-attribute

role: Literal['assistant'] = 'assistant'

The role identifier for assistant messages.

status class-attribute instance-attribute

status: (
    Literal["in_progress", "completed", "incomplete"] | None
) = None

The status of the assistant's response.

content instance-attribute

content: list[
    Annotated[
        AssistantText | AssistantAudio,
        Field(discriminator="type"),
    ]
]

List of content items from the assistant, can be text or audio.

RealtimeToolCallItem

Bases: BaseModel

A tool call item in realtime conversations.

Source code in src/agents/realtime/items.py
class RealtimeToolCallItem(BaseModel):
    """A tool call item in realtime conversations."""

    item_id: str
    """Unique identifier for this tool call item."""

    previous_item_id: str | None = None
    """ID of the previous item in the conversation."""

    call_id: str | None
    """The call ID for this tool invocation."""

    type: Literal["function_call"] = "function_call"
    """The type identifier for function call items."""

    status: Literal["in_progress", "completed"]
    """The status of the tool call execution."""

    arguments: str
    """The JSON string arguments passed to the tool."""

    name: str
    """The name of the tool being called."""

    output: str | None = None
    """The output result from the tool execution."""

    # Allow extra data
    model_config = ConfigDict(extra="allow")

item_id instance-attribute

item_id: str

Unique identifier for this tool call item.

previous_item_id class-attribute instance-attribute

previous_item_id: str | None = None

ID of the previous item in the conversation.

call_id instance-attribute

call_id: str | None

The call ID for this tool invocation.

type class-attribute instance-attribute

type: Literal['function_call'] = 'function_call'

The type identifier for function call items.

status instance-attribute

status: Literal['in_progress', 'completed']

The status of the tool call execution.

arguments instance-attribute

arguments: str

The JSON string arguments passed to the tool.

name instance-attribute

name: str

The name of the tool being called.

output class-attribute instance-attribute

output: str | None = None

The output result from the tool execution.

RealtimeResponse

Bases: BaseModel

A response from the realtime model.

Source code in src/agents/realtime/items.py
class RealtimeResponse(BaseModel):
    """A response from the realtime model."""

    id: str
    """Unique identifier for this response."""

    output: list[RealtimeMessageItem]
    """List of message items in the response."""

id instance-attribute

id: str

Unique identifier for this response.

output instance-attribute

output: list[RealtimeMessageItem]

List of message items in the response.