Client SDK · Chat

Chat.

Send messages and get complete responses from the chat API.

chat.create(params, options?)

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

TypeScript
const response = await client.chat.create({
  input: 'What is the capital of Australia?',
  conversationId: 'conv-123',
  responseMode: 'instant',
});

console.log(response.outputText);
console.log(response.usage);

ChatCreateParams

Fieldtypedescription
inputstringThe user's message. Required if messages is not provided.
messagesApiMessage[]Explicit message array. Overrides input. Each message: { role: 'user' | 'assistant', content: string }.
conversationIdstringAssociates this message with a conversation thread for multi-turn chat.
fileIdsstring[]File IDs to attach (from files.upload()).
responseModeChatResponseModeResponse depth: 'auto', 'instant', or 'deep'. Defaults to 'auto'.
responseSchemastringRaw JSON Schema (as a string) to grammar-constrain the response to. Prefer chat.streamObject / chat.createObject, which convert a zod schema for you (see Structured output).

MatildaRequestOptions

Extends RequestOptions. All fields optional.

Fieldtypedescription
fingerprintstring | nullDevice fingerprint for rate limiting.
accessTokenstring | nullOverride the client-level access token for this request.
signalAbortSignalAbort the request.
stallTimeoutMsnumberSSE stall watchdog timeout in ms. Defaults to 45_000. Pass 0 to disable.
onEvent(event: MatildaChatStreamEvent) => voidCatch-all stream event hook — fires for every event. Only honoured by convenience methods that consume the stream for you (chat.create(), chat.createObject()); use chat.stream() when you want to process events yourself.

MatildaChatResponse

Fieldtypedescription
outputTextstringThe full assistant response text.
eventsMatildaChatStreamEvent[]Every event emitted during the stream.
streamIdstring | undefinedDurable stream ID (from stream_init event).
lastEventIdstring | undefinedLast Redis stream entry ID (for resume).
usageUsageEvent | undefinedToken usage data.
errorsArray<{ code: ChatErrorCode; message: string }>Any errors emitted during the stream.
truncatedReasonstring | undefinedWhy the response was truncated (e.g. 'max_tokens').

ChatResponseMode

TypeScript
type ChatResponseMode = 'auto' | 'instant' | 'deep';
  • 'auto' — Server decides the optimal response depth.
  • 'instant' — Optimised for low latency.
  • 'deep' — Optimised for thoroughness.