yera.models.interfaces.llms._openai_responses

Shared wire helpers for OpenAI-compatible Responses transports.

Symbols

def build_openai_structured_text — Build a strict Responses structured-output definition.
def is_openai_rate_limit — Return whether an OpenAI-compatible error indicates rate limiting.
def openai_retry_wait — Extract a provider-requested retry delay from an error message.
def stream_openai_response — Stream thinking and response tokens from a Responses API call.
def to_openai_wire — Render workspace messages into the Responses input format.

build_openai_structured_text

build_openai_structured_text() → dict

Build a strict Responses structured-output definition.

Parameters

cls
type: type[TStruct]

Struct class defining the required output.

Returns

type: dict

The Responses API text configuration.

is_openai_rate_limit

is_openai_rate_limit(
    exc: Exception,
) → bool

Return whether an OpenAI-compatible error indicates rate limiting.

Parameters

exc
type: Exception

Provider exception to inspect.

Returns

type: bool

Whether the exception represents a rate-limit or overload response.

openai_retry_wait

openai_retry_wait(
    message: str,
) → float

Extract a provider-requested retry delay from an error message.

Parameters

message
type: str

Provider error text.

Returns

type: float

The parsed delay in seconds, or the default retry delay when absent.

stream_openai_response

stream_openai_response(
    client: OpenAI,
    kws: dict,
) → Iterator[LLMToken]

Stream thinking and response tokens from a Responses API call.

Parameters

client
type: OpenAI

OpenAI-compatible client exposing the Responses API.

kws
type: dict

Responses API request parameters.

to_openai_wire

to_openai_wire(
    messages: list[Message],
) → list[dict]

Render workspace messages into the Responses input format.

Parameters

messages
type: list[Message]

The workspace conversation history.

Returns

type: list[dict]

Input items in the Responses API wire format.

Raises

ValueError

If a message cannot be represented in Responses format.