Chat
Generate a model response for a conversation. Supports streaming, tool calling, structured outputs and reasoning.
Create chat completion
Creates a model response for the given conversation. Set `stream: true` to receive the response as a stream of server-sent events. The last chunk before `data: [DONE]` carries the `usage` object on every stream, whether or not `stream_options.include_usage` is set. An error after the stream has started (the API commits a stream that the model has not answered within 2 seconds, and keeps it alive with `: ping` comment lines) arrives as a final `data:` event whose JSON has an `error` member, the usual error object, followed by `data: [DONE]`; see the [streaming guide](/docs/streaming#errors-during-a-stream).