Client SDK · Chat

Chat.

Send messages and get complete responses from the chat API.

chat.create(...)

Sends a chat message and returns the complete response. Internally this runs the stream and collects all events.

Python
async def main():
    async with MatildaClient(token="...") as client:
        response = await client.chat.create(
            input="What is the capital of Australia?",
            conversation_id="conv-123",
            response_mode="instant",
        )

        print(response.output_text)
        print(response.usage)

Parameters

Fieldtypedescription
inputstr | NoneThe user's message. Required if messages is not provided.
messageslist[dict] | NoneExplicit message array. Overrides input. Each message: { role: 'user' | 'assistant', content: str }.
conversation_idstr | NoneAssociates this message with a conversation thread for multi-turn chat.
file_idslist[str] | NoneFile IDs to attach (from files.upload()).
response_modestr | NoneResponse depth: 'auto', 'instant', or 'deep'. Defaults to 'auto'.
response_schemastr | NoneRaw JSON Schema (as a string) to grammar-constrain the response to. Prefer chat.stream_object / chat.create_object, which convert a pydantic model for you (see Structured output).
access_tokenstr | NoneOverride the client-level access token for this request.
fingerprintstr | NoneDevice fingerprint for rate limiting.
stall_timeout_msint | NoneSSE stall watchdog timeout in ms. Defaults to 45_000. Pass 0 to disable.
on_eventCallable[[ChatEvent], None] | NoneCatch-all stream event hook — fires for every event. Only honoured by convenience methods that consume the stream for you (chat.create(), chat.create_object()); use chat.stream() when you want to process events yourself.

MatildaChatResponse

Fieldtypedescription
output_textstrThe full assistant response text.
eventslist[ChatEvent]Every event emitted during the stream.
stream_idstr | NoneDurable stream ID (from the response.created event).
last_event_idstr | NoneLast Redis stream entry ID (for resume).
usageUsage | NoneToken usage data.
errorslist[StreamErrorInfo]Any errors emitted during the stream.
truncated_reasonstr | NoneWhy the response was truncated (e.g. 'max_tokens').

Response modes

  • 'auto' — Server decides the optimal response depth.
  • 'instant' — Optimised for low latency.
  • 'deep' — Optimised for thoroughness.