# Chat ## Domain Types ### Completion Message - `class CompletionMessage` A message containing the model's (assistant) response in a chat conversation. - **role:** `Literal["assistant"]` Must be "assistant" to identify this as the model's response - `"assistant"` - **content:** `Optional[Content]` The content of the model's response. - **ContentUnionMember0:** `str` - `MessageTextContentItem` - **stop\_reason:** `Optional[Literal["stop", "tool_calls", "length"]]` The reason why we stopped. Options are: - "stop": The model reached a natural stopping point. - "tool_calls": The model finished generating and invoked a tool call. - "length": The model reached the maxinum number of tokens specified in the request. - `"stop"` - `"tool_calls"` - `"length"` - **tool\_calls:** `Optional[List[ToolCall]]` The tool calls generated by the model, such as function calls. - **id:** `str` The ID of the tool call. - **function:** `ToolCallFunction` The function that the model called. - **arguments:** `str` The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. - **name:** `str` The name of the function to call. ### Create Chat Completion Response - `class CreateChatCompletionResponse` Response from a chat completion request. - **completion\_message:** `CompletionMessage` The complete response message - **id:** `Optional[str]` The unique identifier of the chat completion request. - **metrics:** `Optional[List[Metric]]` - **metric:** `str` - **value:** `float` - **unit:** `Optional[str]` ### Create Chat Completion Response Stream Chunk - `class CreateChatCompletionResponseStreamChunk` A chunk of a streamed chat completion response. - **event:** `Event` The event containing the new content - **delta:** `EventDelta` Content generated since last event. This can be one or more tokens, or a tool call. - `class EventDeltaTextDelta` - **text:** `str` - **type:** `Literal["text"]` - `"text"` - `class EventDeltaToolCallDelta` - **function:** `EventDeltaToolCallDeltaFunction` - **arguments:** `Optional[str]` The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. - **name:** `Optional[str]` The name of the function to call. - **type:** `Literal["tool_call"]` - `"tool_call"` - **id:** `Optional[str]` The ID of the tool call. - **event\_type:** `Literal["start", "complete", "progress", "metrics"]` Type of the event - `"start"` - `"complete"` - `"progress"` - `"metrics"` - **metrics:** `Optional[List[EventMetric]]` - **metric:** `str` - **value:** `float` - **unit:** `Optional[str]` - **stop\_reason:** `Optional[Literal["stop", "tool_calls", "length"]]` The reason why we stopped. Options are: - "stop": The model reached a natural stopping point. - "tool_calls": The model finished generating and invoked a tool call. - "length": The model reached the maxinum number of tokens specified in the request. - `"stop"` - `"tool_calls"` - `"length"` - **id:** `Optional[str]` The unique identifier of the chat completion request. ### Message - **Message:** `Message` A message from the user in a chat conversation. - `UserMessage` - `SystemMessage` - `ToolResponseMessage` - `CompletionMessage` ### Message Image Content Item - `class MessageImageContentItem` A image content item - **image\_url:** `ImageURL` Contains either an image URL or a data URL for a base64 encoded image. - **url:** `str` Either a URL of the image or the base64 encoded image data. - **type:** `Literal["image_url"]` Discriminator type of the content item. Always "image" - `"image_url"` ### Message Text Content Item - `class MessageTextContentItem` A text content item - **text:** `str` Text content - **type:** `Literal["text"]` Discriminator type of the content item. Always "text" - `"text"` ### System Message - `class SystemMessage` A system message providing instructions or context to the model. - **content:** `Union[str, List[MessageTextContentItem]]` The content of the system message. - **ContentTextContent:** `str` The text contents of the message. - **ContentArrayOfContentItems:** `List[MessageTextContentItem]` A list of content items, which can include text and other media. Supported content types differ based on model. - **text:** `str` Text content - **type:** `Literal["text"]` Discriminator type of the content item. Always "text" - `"text"` - **role:** `Literal["system"]` Must be "system" to identify this as a system message - `"system"` ### Tool Response Message - `class ToolResponseMessage` A message representing the result of a tool invocation. - **content:** `Union[str, List[MessageTextContentItem]]` The content of the user message, which can include text and other media. - **ContentTextContent:** `str` The text contents of the message. - **ContentArrayOfContentItems:** `List[MessageTextContentItem]` A list of content items, which can include text and other media. Supported content types differ based on model. - **text:** `str` Text content - **type:** `Literal["text"]` Discriminator type of the content item. Always "text" - `"text"` - **role:** `Literal["tool"]` Must be "tool" to identify this as a tool response - `"tool"` - **tool\_call\_id:** `str` Unique identifier for the tool call this response is for ### User Message - `class UserMessage` A message from the user in a chat conversation. - **content:** `Union[str, List[ContentArrayOfContentItem]]` The content of the user message, which can include text and other media. - **ContentTextContent:** `str` The text contents of the message. - **ContentArrayOfContentItems:** `List[ContentArrayOfContentItem]` A list of content items, which can include text and other media. Supported content types differ based on model. - `MessageTextContentItem` - `MessageImageContentItem` - **role:** `Literal["user"]` Must be "user" to identify this as a user message. - `"user"`