Models API Reference
- class llm_async.models.message.Message(role: Literal['system', 'user', 'assistant', 'tool'], content: str | list[dict[str, Any]], tool_calls: list[ToolCall] | None = None, reasoning: str | None = None, reasoning_details: list[dict[str, Any] | str] | None = None, stop_reason: str | None = None, original: dict[str, Any] | None = None)[source]
Bases:
objectRepresents a single chat message.
The preferred way to build messages for
acomplete. Accepts plain dicts as well, but usingMessageprovides role validation and type safety.Example:
from llm_async.models.message import Message messages = [ Message("system", "You are a helpful assistant."), Message("user", "Hello, how are you?"), ]
- Args:
role: One of
"system","user","assistant","tool". content: Text content or a list of content parts (for multimodal). tool_calls: Optional list of tool calls attached to this message. original: Raw provider payload, used internally when round-tripping responses.
- llm_async.models.message.normalize_messages(messages: Sequence[Message | Mapping[str, Any]]) list[Message][source]
- class llm_async.models.response.Response(original: 'dict[str, Any]', provider_name: 'str', main_response: 'Message | None' = None, stream: 'bool' = False, stream_generator: 'AsyncIterator[StreamChunk] | None' = None)[source]
Bases:
object- async stream_content() AsyncIterator[str][source]
Convenience method to iterate over stream content
- stream_generator: AsyncIterator[StreamChunk] | None = None[source]
- class llm_async.models.response.StreamChunk(content: str | None, original: dict[str, Any])[source]
Bases:
objectRepresents a single chunk from a streaming response.
content: the textual content of the chunk (may be None)
original: the original parsed JSON chunk from the provider
- class llm_async.models.tool_call.ToolCall(id: 'str', type: 'str', name: 'str | None' = None, input: 'dict[str, Any] | None' = None, function: 'dict[str, Any] | None' = None)[source]
Bases:
object- static from_responses_api_function_call(fc_id: str, call_id: str, name: str, arguments: str) ToolCall[source]
Create ToolCall from Responses API function call.
- class llm_async.models.response_schema.ResponseSchema(schema: 'Mapping[str, Any]', name: 'str' = 'response', strict: 'bool' = True, mime_type: 'str' = 'application/json')[source]
Bases:
object- classmethod coerce(value: ResponseSchema | Mapping[str, Any] | None) ResponseSchema | None[source]
- class llm_async.models.event.Event(topic: str, payload: dict[str, Any], timestamp: datetime)[source]
Bases:
objectRepresents a pub/sub event for tool execution.