Skip to main content

Class: ChatResponse

A dataclass returned by every chat() and chat_sync() call. Provides typed access to the response and metadata.

Fields

str
The AI’s response text. This is what you display to the user.
"success" | "error"
Whether the request succeeded. "success" means the LLM returned a valid response. "error" means something went wrong (LLM failure, timeout, etc.).
str
The user_id you passed to chat(). Echoed back for convenience.
str
The platform you passed to chat(). Defaults to "default".
float
End-to-end latency in seconds, from when chat() was called to when the response was ready.
str
UTC timestamp of the response in ISO 8601 format (e.g. "2025-01-15T10:30:00.000Z").
str | None
Error message when status == "error". None on success.

Special methods

__bool__

if response: returns True when status == "success".

__str__

print(response) and str(response) return response.text.

Usage patterns

Basic

With error handling

In an API response

In a chat loop