# Chat ## Domain Types ### Completion Message - `CompletionMessage` A message containing the model's (assistant) response in a chat conversation. - **role:** `"assistant"` Must be "assistant" to identify this as the model's response - `"assistant"` - **content:** `string | MessageTextContentItem` The content of the model's response. - `string` - `MessageTextContentItem` - **stop\_reason:** `"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:** `Array` The tool calls generated by the model, such as function calls. - **id:** `string` The ID of the tool call. - **function:** `Function` The function that the model called. - **arguments:** `string` 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:** `string` The name of the function to call. ### Create Chat Completion Response - `CreateChatCompletionResponse` Response from a chat completion request. - **completion\_message:** `CompletionMessage` The complete response message - **id:** `string` The unique identifier of the chat completion request. - **metrics:** `Array` - **metric:** `string` - **value:** `number` - **unit:** `string` ### Create Chat Completion Response Stream Chunk - `CreateChatCompletionResponseStreamChunk` A chunk of a streamed chat completion response. - **event:** `Event` The event containing the new content - **delta:** `TextDelta | ToolCallDelta` Content generated since last event. This can be one or more tokens, or a tool call. - `TextDelta` - **text:** `string` - **type:** `"text"` - `"text"` - `ToolCallDelta` - **function:** `Function` - **arguments:** `string` 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:** `string` The name of the function to call. - **type:** `"tool_call"` - `"tool_call"` - **id:** `string` The ID of the tool call. - **event\_type:** `"start" | "complete" | "progress" | "metrics"` Type of the event - `"start"` - `"complete"` - `"progress"` - `"metrics"` - **metrics:** `Array` - **metric:** `string` - **value:** `number` - **unit:** `string` - **stop\_reason:** `"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:** `string` The unique identifier of the chat completion request. ### Message - **Message:** `UserMessage | SystemMessage | ToolResponseMessage | CompletionMessage` A message from the user in a chat conversation. - `UserMessage` - `SystemMessage` - `ToolResponseMessage` - `CompletionMessage` ### Message Image Content Item - `MessageImageContentItem` A image content item - **image\_url:** `ImageURL` Contains either an image URL or a data URL for a base64 encoded image. - **url:** `string` Either a URL of the image or the base64 encoded image data. - **type:** `"image_url"` Discriminator type of the content item. Always "image" - `"image_url"` ### Message Text Content Item - `MessageTextContentItem` A text content item - **text:** `string` Text content - **type:** `"text"` Discriminator type of the content item. Always "text" - `"text"` ### System Message - `SystemMessage` A system message providing instructions or context to the model. - **content:** `string | Array` The content of the system message. - `string` - `Array` - **role:** `"system"` Must be "system" to identify this as a system message - `"system"` ### Tool Response Message - `ToolResponseMessage` A message representing the result of a tool invocation. - **content:** `string | Array` The content of the user message, which can include text and other media. - `string` - `Array` - **role:** `"tool"` Must be "tool" to identify this as a tool response - `"tool"` - **tool\_call\_id:** `string` Unique identifier for the tool call this response is for ### User Message - `UserMessage` A message from the user in a chat conversation. - **content:** `string | Array` The content of the user message, which can include text and other media. - `string` - `Array` - **role:** `"user"` Must be "user" to identify this as a user message. - `"user"`