> This page is for version v2 API (default).
> For other versions, use one of these documentation indexes:
> - v2 API (default): https://docs.cohere.com/v2/llms.txt
> - v1 API: https://docs.cohere.com/v1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cohere.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cohere.com/_mcp/server.

# Chat with Streaming

POST https://api.cohere.com/v2/chat
Content-Type: application/json

Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api).

Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.


Reference: https://docs.cohere.com/reference/chat-stream

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `X-Client-Name` (string, optional) — The name of the project that is making the request.

### Body (application/json)

This endpoint expects an object.

- `stream` (true, required) — Defaults to `false`. When `true`, the response will be a SSE stream of events. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated.
- `model` (string, required) — The name of a compatible [Cohere model](https://docs.cohere.com/v2/docs/models).
- `messages` (list of ChatMessageV2, required) — A list of chat messages in chronological order, representing a conversation between the user and the model. Messages can be from `User`, `Assistant`, `Tool` and `System` roles. Learn more about messages and roles in [the Chat API guide](https://docs.cohere.com/v2/docs/chat-api).
- `tools` (list of ToolV2, optional) — A list of tools (functions) available to the model. The model response may contain 'tool_calls' to the specified tools. Learn more in the [Tool Use guide](https://docs.cohere.com/docs/tools).
- `documents` (list of V2ChatPostRequestBodyContentApplicationJsonSchemaDocumentsItems, optional) — A list of relevant documents that the model can cite to generate a more accurate reply. Each document is either a string or document object with content and metadata.
- `citation_options` (CitationOptions, optional) — Options for controlling citation generation.
- `response_format` (ResponseFormatV2, optional) — Configuration for forcing the model output to adhere to the specified format. Supported on [Command R](https://docs.cohere.com/v2/docs/command-r), [Command R+](https://docs.cohere.com/v2/docs/command-r-plus) and newer models. The model can be forced into outputting JSON objects by setting `{ "type": "json_object" }`. A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: *"Generate a JSON ..."*) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting. **Limitation**: The parameter is not supported when used in combinations with the `documents` or `tools` parameters.
- `safety_mode` (enum, optional) — Used to select the [safety instruction](https://docs.cohere.com/v2/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `OFF` is specified, the safety instruction will be omitted. Safety modes are not yet configurable in combination with `tools` and `documents` parameters. **Note**: This parameter is only compatible newer Cohere models, starting with [Command R 08-2024](https://docs.cohere.com/docs/command-r#august-2024-release) and [Command R+ 08-2024](https://docs.cohere.com/docs/command-r-plus#august-2024-release). **Note**: `command-r7b-12-2024` and newer models only support `"CONTEXTUAL"` and `"STRICT"` modes.
  - Allowed values: `CONTEXTUAL`, `STRICT`, `OFF`
- `max_tokens` (integer, optional) — The maximum number of output tokens the model will generate in the response. If not set, `max_tokens` defaults to the model's maximum output token limit. You can find the maximum output token limits for each model in the [model documentation](https://docs.cohere.com/docs/models). **Note**: Setting a low value may result in incomplete generations. In such cases, the `finish_reason` field in the response will be set to `"MAX_TOKENS"`. **Note**: If `max_tokens` is set higher than the model's maximum output token limit, the generation will be capped at that model-specific maximum limit.
- `stop_sequences` (list of string, optional) — A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence.
- `temperature` (double, optional) — Defaults to `0.3`. A non-negative float that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. Randomness can be further maximized by increasing the value of the `p` parameter.
- `seed` (integer, optional) — If specified, the backend will make a best effort to sample tokens deterministically, such that repeated requests with the same seed and parameters should return the same result. However, determinism cannot be totally guaranteed.
- `frequency_penalty` (double, optional) — Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation.
- `presence_penalty` (double, optional) — Defaults to `0.0`, min value of `0.0`, max value of `1.0`. Used to reduce repetitiveness of generated tokens. Similar to `frequency_penalty`, except that this penalty is applied equally to all tokens that have already appeared, regardless of their exact frequencies.
- `k` (integer, optional, default: 0) — Ensures that only the top `k` most likely tokens are considered for generation at each step. When `k` is set to `0`, k-sampling is disabled. Defaults to `0`, min value of `0`, max value of `500`.
- `p` (double, optional, default: 0.75) — Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`. Defaults to `0.75`. min value of `0.01`, max value of `0.99`.
- `logprobs` (boolean, optional) — Defaults to `false`. When set to `true`, the log probabilities of the generated tokens will be included in the response.
- `tool_choice` (enum, optional) — Used to control whether or not the model will be forced to use a tool when answering. When `REQUIRED` is specified, the model will be forced to use at least one of the user-defined tools, and the `tools` parameter must be passed in the request. When `NONE` is specified, the model will be forced **not** to use one of the specified tools, and give a direct response. If tool_choice isn't specified, then the model is free to choose whether to use the specified tools or not. **Note**: This parameter is only compatible with models [Command-r7b](https://docs.cohere.com/v2/docs/command-r7b) and newer.
  - Allowed values: `REQUIRED`, `NONE`
- `thinking` (Thinking, optional) — Configuration for [reasoning features](https://docs.cohere.com/docs/reasoning).
- `priority` (integer, optional, default: 0) — Controls how early the request is handled. Lower numbers indicate higher priority (default: 0, the highest). When the system is under load, higher-priority requests are processed first and are the least likely to be dropped.
- `strict_tools` (boolean, optional) — When set to `true`, tool calls in the Assistant message will be forced to follow the tool definition strictly. Learn more in the [Structured Outputs (Tools) guide](https://docs.cohere.com/docs/structured-outputs-json#structured-outputs-tools). **Note**: The first few requests with a new set of tools will take longer to process.

## Response

### 200

Generates a text response to a user message. To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/v2/docs/chat-api). Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2) for instructions on moving from API v1 to API v2.

- Streaming response of `v2_chat_Response_stream_streaming`.
- `type`: `message-start` (message-start)
  - `delta` (ChatMessageStartEventDelta, optional)
  - `id` (string, optional) — Unique identifier for the generated reply.
- `type`: `content-start` (content-start)
  - `delta` (ChatContentStartEventDelta, optional)
  - `index` (integer, optional)
- `type`: `content-delta` (content-delta)
  - `delta` (ChatContentDeltaEventDelta, optional)
  - `index` (integer, optional)
  - `logprobs` (LogprobItem, optional)
- `type`: `content-end` (content-end)
  - `index` (integer, optional)
- `type`: `tool-plan-delta` (tool-plan-delta)
  - `delta` (ChatToolPlanDeltaEventDelta, optional)
- `type`: `tool-call-start` (tool-call-start)
  - `delta` (ChatToolCallStartEventDelta, optional)
  - `index` (integer, optional)
- `type`: `tool-call-delta` (tool-call-delta)
  - `delta` (ChatToolCallDeltaEventDelta, optional)
  - `index` (integer, optional)
- `type`: `tool-call-end` (tool-call-end)
  - `index` (integer, optional)
- `type`: `citation-start` (citation-start)
  - `delta` (CitationStartEventDelta, optional)
  - `index` (integer, optional)
- `type`: `citation-end` (citation-end)
  - `index` (integer, optional)
- `type`: `message-end` (message-end)
  - `delta` (ChatMessageEndEventDelta, optional)
  - `id` (string, optional)
- `type`: `debug` (debug)
  - `event_type` (enum, required)
    - Allowed values: `stream-start`, `search-queries-generation`, `search-results`, `text-generation`, `citation-generation`, `stream-end`, `debug`
  - `prompt` (string, optional)

## Errors

### 400 Bad Request Error

This error is returned when the request is not well formed. This could be because: - JSON is invalid - The request is missing required fields - The request contains an invalid combination of fields

- `message` (string, optional)
- `id` (string, optional)

### 401 Unauthorized Error

This error indicates that the operation attempted to be performed is not allowed. This could be because: - The api token is invalid - The user does not have the necessary permissions

- `message` (string, optional)
- `id` (string, optional)

### 403 Forbidden Error

This error indicates that the operation attempted to be performed is not allowed. This could be because: - The api token is invalid - The user does not have the necessary permissions

- `message` (string, optional)
- `id` (string, optional)

### 404 Not Found Error

This error is returned when a resource is not found. This could be because: - The endpoint does not exist - The resource does not exist eg model id, dataset id

- `message` (string, optional)
- `id` (string, optional)

### 422 Unprocessable Entity Error

This error is returned when the request is not well formed. This could be because: - JSON is invalid - The request is missing required fields - The request contains an invalid combination of fields

- `message` (string, optional)
- `id` (string, optional)

### 429 Too Many Requests Error

Too many requests

- `message` (string, optional)
- `id` (string, optional)

### 498 Invalid Token Error

This error is returned when a request or response contains a deny-listed token.

- `message` (string, optional)
- `id` (string, optional)

### 499 Client Closed Request Error

This error is returned when a request is cancelled by the user.

- `message` (string, optional)
- `id` (string, optional)

### 500 Internal Server Error

This error is returned when an uncategorised internal server error occurs.

- `message` (string, optional)
- `id` (string, optional)

### 501 Not Implemented Error

This error is returned when the requested feature is not implemented.

- `message` (string, optional)
- `id` (string, optional)

### 503 Service Unavailable Error

This error is returned when the service is unavailable. This could be due to: - Too many users trying to access the service at the same time

- `message` (string, optional)
- `id` (string, optional)

### 504 Gateway Timeout Error

This error is returned when a request to the server times out. This could be due to: - An internal services taking too long to respond

- `message` (string, optional)
- `id` (string, optional)

## Types

### ChatMessageV2

Represents a single message in the chat history from a given role.

- `role`: `user` (User Message)
  - `content` (ChatMessageV2DiscriminatorMappingUserContent, required) — The content of the message. This can be a string or a list of content blocks. If a string is provided, it will be treated as a text content block.
- `role`: `assistant` (Assistant Message)
  - `citations` (list of Citation, optional)
  - `content` (AssistantMessageV2Content, optional)
  - `tool_calls` (list of ToolCallV2, optional)
  - `tool_plan` (string, optional) — A chain-of-thought style reflection and plan that the model generates when working with Tools.
- `role`: `system` (System Message)
  - `content` (ChatMessageV2DiscriminatorMappingSystemContent, required)
- `role`: `tool` (Tool Message)
  - `content` (ChatMessageV2DiscriminatorMappingToolContent, required) — Outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks
  - `tool_call_id` (string, required) — The id of the associated tool call that has provided the given content

### ToolV2

- `type` (enum, required)
  - Allowed values: `function`
- `function` (ToolV2Function, optional) — The function to be executed.

### V2ChatPostRequestBodyContentApplicationJsonSchemaDocumentsItems

### CitationOptions

Options for controlling citation generation.

- `mode` (enum, optional) — Defaults to `"enabled"`. Citations are enabled by default for models that support it, but can be turned off by setting `"type": "disabled"`.
  - Allowed values: `ENABLED`, `DISABLED`, `FAST`, `ACCURATE`, `OFF`

### ResponseFormatV2

Configuration for forcing the model output to adhere to the specified format. Supported on [Command R](https://docs.cohere.com/v2/docs/command-r), [Command R+](https://docs.cohere.com/v2/docs/command-r-plus) and newer models. The model can be forced into outputting JSON objects by setting `{ "type": "json_object" }`. A [JSON Schema](https://json-schema.org/) can optionally be provided, to ensure a specific structure. **Note**: When using `{ "type": "json_object" }` your `message` should always explicitly instruct the model to generate a JSON (eg: *"Generate a JSON ..."*) . Otherwise the model may end up getting stuck generating an infinite stream of characters and eventually run out of context length. **Note**: When `json_schema` is not specified, the generated object can have up to 5 layers of nesting. **Limitation**: The parameter is not supported when used in combinations with the `documents` or `tools` parameters.

- `type`: `text` (text)
- `type`: `json_object` (json_object)
  - `json_schema` (JsonResponseFormatV2-uu9wid, optional) — A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. Example (required name and age object): ```json { "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }, "required": ["name", "age"] } ``` **Note**: This field must not be specified when the `type` is set to `"text"`.

### Thinking

Configuration for [reasoning features](https://docs.cohere.com/docs/reasoning).

- `type` (enum, required) — Reasoning is enabled by default for models that support it, but can be turned off by setting `"type": "disabled"`.
  - Allowed values: `enabled`, `disabled`
- `token_budget` (integer, optional) — The maximum number of tokens the model can use for thinking, which must be set to a positive integer. The model will stop thinking if it reaches the thinking token budget and will proceed with the response.

### ChatMessageStartEventDelta

- `message` (ChatMessageStartEventDeltaMessage, optional)

### ChatContentStartEventDelta

- `message` (ChatContentStartEventDeltaMessage, optional)

### ChatContentDeltaEventDelta

- `message` (ChatContentDeltaEventDeltaMessage, optional)

### LogprobItem

- `token_ids` (list of integer, required) — The token ids of each token used to construct the text chunk.
- `text` (string, optional) — The text chunk for which the log probabilities was calculated.
- `logprobs` (list of double, optional) — The log probability of each token used to construct the text chunk.

### ChatToolPlanDeltaEventDelta

- `message` (ChatToolPlanDeltaEventDeltaMessage, optional)

### ChatToolCallStartEventDelta

- `message` (ChatToolCallStartEventDeltaMessage, optional)

### ChatToolCallDeltaEventDelta

- `message` (ChatToolCallDeltaEventDeltaMessage, optional)

### CitationStartEventDelta

- `message` (CitationStartEventDeltaMessage, optional)

### ChatMessageEndEventDelta

- `error` (string, optional) — An error message if an error occurred during the generation.
- `finish_reason` (enum, optional) — The reason a chat request has finished. - **complete**: The model finished sending a complete message. - **max_tokens**: The number of generated tokens exceeded the model's context length or the value specified via the `max_tokens` parameter. - **stop_sequence**: One of the provided `stop_sequence` entries was reached in the model's generation. - **tool_call**: The model generated a Tool Call and is expecting a Tool Message in return - **error**: The generation failed due to an internal error - **timeout**: The generation was stopped because it exceeded the allowed time limit.
  - Allowed values: `COMPLETE`, `STOP_SEQUENCE`, `MAX_TOKENS`, `TOOL_CALL`, `ERROR`, `TIMEOUT`
- `usage` (Usage, optional)

### ChatMessageV2DiscriminatorMappingUserContent

The content of the message. This can be a string or a list of content blocks. If a string is provided, it will be treated as a text content block.

### Citation

Citation information containing sources and the text cited.

- `start` (integer, optional) — Start index of the cited snippet in the original source text.
- `end` (integer, optional) — End index of the cited snippet in the original source text.
- `text` (string, optional) — Text snippet that is being cited.
- `sources` (list of Source, optional)
- `content_index` (integer, optional) — Index of the content block in which this citation appears.
- `type` (enum, optional) — The type of citation which indicates what part of the response the citation is for.
  - Allowed values: `TEXT_CONTENT`, `THINKING_CONTENT`, `PLAN`

### AssistantMessageV2Content

### ToolCallV2

An array of tool calls to be made.

- `id` (string, required)
- `type` (enum, required)
  - Allowed values: `function`
- `function` (ToolCallV2Function, optional)

### ChatMessageV2DiscriminatorMappingSystemContent

### ChatMessageV2DiscriminatorMappingToolContent

Outputs from a tool. The content should formatted as a JSON object string, or a list of tool content blocks

### ToolV2Function

The function to be executed.

- `name` (string, required) — The name of the function.
- `parameters` (ToolV2-6eoehf, required) — The parameters of the function as a JSON schema.
- `description` (string, optional) — The description of the function.

### Document

Relevant information that could be used by the model to generate a more accurate reply. The content of each document are generally short (should be under 300 words). Metadata should be used to provide additional information, both the key name and the value will be passed to the model.

- `data` (Document-qmvpd9, required) — A relevant document that the model can cite to generate a more accurate reply. Each document is a string-any dictionary.
- `id` (string, optional) — Unique identifier for this document which will be referenced in citations. If not provided an ID will be automatically generated.

### JsonResponseFormatV2-uu9wid

A [JSON schema](https://json-schema.org/overview/what-is-jsonschema) object that the output will adhere to. There are some restrictions we have on the schema, refer to [our guide](https://docs.cohere.com/docs/structured-outputs-json#schema-constraints) for more information. Example (required name and age object): ```json { "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }, "required": ["name", "age"] } ``` **Note**: This field must not be specified when the `type` is set to `"text"`.

### ChatMessageStartEventDeltaMessage

- `role` (enum, optional) — The role of the message.
  - Allowed values: `assistant`

### ChatContentStartEventDeltaMessage

- `content` (ChatContentStartEventDeltaMessageContent, optional)

### ChatContentDeltaEventDeltaMessage

- `content` (ChatContentDeltaEventDeltaMessageContent, optional)

### ChatToolPlanDeltaEventDeltaMessage

- `tool_plan` (string, optional)

### ChatToolCallStartEventDeltaMessage

- `tool_calls` (ToolCallV2, optional) — An array of tool calls to be made.

### ChatToolCallDeltaEventDeltaMessage

- `tool_calls` (ChatToolCallDeltaEventDeltaMessageToolCalls, optional)

### CitationStartEventDeltaMessage

- `citations` (Citation, optional) — Citation information containing sources and the text cited.

### Usage

- `billed_units` (UsageBilledUnits, optional)
- `tokens` (UsageTokens, optional)
- `cached_tokens` (double, optional) — The number of prompt tokens that hit the inference cache.

### Source

A source object containing information about the source of the data cited.

- `type`: `tool` (Tool Output)
  - `id` (string, optional) — The unique identifier of the document
  - `tool_output` (map from string to any, optional)
- `type`: `document` (document)
  - `document` (map from string to any, optional)
  - `id` (string, optional) — The unique identifier of the document

### ToolCallV2Function

- `name` (string, optional)
- `arguments` (string, optional)

### ToolV2-6eoehf

The parameters of the function as a JSON schema.

### Document-qmvpd9

A relevant document that the model can cite to generate a more accurate reply. Each document is a string-any dictionary.

### ChatContentStartEventDeltaMessageContent

- `thinking` (string, optional)
- `text` (string, optional)
- `type` (enum, optional)
  - Allowed values: `text`, `thinking`

### ChatContentDeltaEventDeltaMessageContent

- `thinking` (string, optional)
- `text` (string, optional)

### ChatToolCallDeltaEventDeltaMessageToolCalls

- `function` (ChatToolCallDeltaEventDeltaMessageToolCallsFunction, optional)

### UsageBilledUnits

- `input_tokens` (double, optional) — The number of billed input tokens.
- `output_tokens` (double, optional) — The number of billed output tokens.
- `search_units` (double, optional) — The number of billed search units.
- `classifications` (double, optional) — The number of billed classifications units.

### UsageTokens

- `input_tokens` (double, optional) — The number of tokens used as input to the model.
- `output_tokens` (double, optional) — The number of tokens produced by the model.

### ChatToolCallDeltaEventDeltaMessageToolCallsFunction

- `arguments` (string, optional)

## Examples

### Default

**Request**

```json
{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Tell me about LLMs"
    }
  ]
}
```

**Response**

```text
event: message-start
data: {"delta":{"message":{"role":"assistant"}},"id":"29f14a5a-11de-4cae-9800-25e4747408ea","type":"message-start"}

event: content-start
data: {"delta":{"message":{"content":{"text":"","type":"text"}}},"index":0,"type":"content-start"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"LL"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"Ms"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" stand"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" for"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Large"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Language"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Models"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" which"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" are"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" type"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" of"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" neural"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" network"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" model"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" specialized"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" in"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" processing"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" and"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" generating"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" human"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" language"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"index":0,"type":"content-delta"}

event: content-end
data: {"index":0,"type":"content-end"}

event: message-end
data: {"delta":{"finish_reason":"COMPLETE","usage":{"billed_units":{"input_tokens":5,"output_tokens":26},"tokens":{"input_tokens":71,"output_tokens":26}}},"type":"message-end"}
```

**SDK Code**

```typescript Default
const { CohereClientV2 } = require('cohere-ai');

const cohere = new CohereClientV2({});

(async () => {
  const stream = await cohere.chatStream({
    model: 'command-a-plus-05-2026',
    messages: [
      {
        role: 'user',
        content: 'Tell me about LLMs',
      },
    ],
  });

  for await (const chatEvent of stream) {
    if (chatEvent.type === 'content-delta') {
      console.log(chatEvent.delta?.message);
    }
  }
})();

```

```python Default
import cohere

co = cohere.ClientV2()

response = co.chat_stream(
    model="command-a-plus-05-2026",
    messages=[{"role": "user", "content": "Tell me about LLMs"}],
)

for event in response:
    if event.type == "content-delta":
        print(event.delta.message.content.text, end="")

```

```java Default
/* (C)2024 */
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatStreamRequest;
import com.cohere.api.types.*;
import java.util.List;

public class Stream {
  public static void main(String[] args) {
    Cohere cohere = Cohere.builder().clientName("snippet").build();

    Iterable<StreamedChatResponseV2> response =
        cohere
            .v2()
            .chatStream(
                V2ChatStreamRequest.builder()
                    .model("command-a-plus-05-2026")
                    .messages(
                        List.of(
                            ChatMessageV2.user(
                                UserMessage.builder()
                                    .content(UserMessageContent.of("Tell me about LLMs"))
                                    .build())))
                    .build());

    for (StreamedChatResponseV2 chatResponse : response) {
      if (chatResponse.isContentDelta()) {
        System.out.println(
            chatResponse
                .getContentDelta()
                .flatMap(ChatContentDeltaEvent::getDelta)
                .flatMap(ChatContentDeltaEventDelta::getMessage)
                .flatMap(ChatContentDeltaEventDeltaMessage::getContent)
                .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)
                .orElse(""));
      }
    }

    System.out.println(response);
  }
}

```

```go Default
package main

import (
	"context"
	"errors"
	"io"
	"log"
	"os"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken(os.Getenv("CO_API_KEY")))

	resp, err := co.V2.ChatStream(
		context.TODO(),
		&cohere.V2ChatStreamRequest{
			Model: "command-a-plus-05-2026",
			Messages: cohere.ChatMessages{
				{
					Role: "user",
					User: &cohere.UserMessageV2{
						Content: &cohere.UserMessageV2Content{
							String: "Tell me about LLMs",
						},
					},
				},
			},
		},
	)

	if err != nil {
		log.Fatal(err)
	}

	// Make sure to close the stream when you're done reading.
	// This is easily handled with defer.
	defer resp.Close()

	for {
		message, err := resp.Recv()

		if errors.Is(err, io.EOF) {
			// An io.EOF error means the server is done sending messages
			// and should be treated as a success.
			break
		}

		if message.ContentDelta != nil {
			log.Printf("%+v", message)
		}
	}
}

```

```ruby Default
require 'uri'
require 'net/http'

url = URI("https://api.cohere.com/v2/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Tell me about LLMs\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```php Default
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cohere.com/v2/chat', [
  'body' => '{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Tell me about LLMs"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Default
using RestSharp;

var client = new RestClient("https://api.cohere.com/v2/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Tell me about LLMs\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    [
      "role": "user",
      "content": "Tell me about LLMs"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v2/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Documents

**Request**

```json
{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Who is more popular: Nsync or Backstreet Boys?"
    }
  ],
  "documents": [
    {
      "data": {
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak."
      }
    },
    {
      "data": {
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold."
      }
    },
    {
      "data": {
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers."
      }
    },
    {
      "data": {
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures."
      }
    }
  ]
}
```

**Response**

```text
event: message-start
data: {"delta":{"message":{"role":"assistant"}},"id":"8268c123-8264-4046-afd9-ae3d328f85f3","type":"message-start"}

event: content-start
data: {"delta":{"message":{"content":{"text":"","type":"text"}}},"index":0,"type":"content-start"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"Both"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Nsync"}}},"index":0,"type":"content-delta"}

event: citation-start
data: {"delta":{"message":{"citations":{"end":10,"sources":[{"document":{"id":"1","snippet":"↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven't study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn't a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.","title":"CSPC: NSYNC Popularity Analysis - ChartMasters"},"id":"1","type":"document"}],"start":5,"text":"Nsync","type":"TEXT_CONTENT"}}},"index":0,"type":"citation-start"}

event: citation-end
data: {"index":0,"type":"citation-end"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" and"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Backstreet"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Boys"}}},"index":0,"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" were"}}},"index":0,"type":"content-delta"}

event: content-end
data: {"index":0,"type":"content-end"}

event: message-end
data: {"delta":{"finish_reason":"COMPLETE","usage":{"billed_units":{"input_tokens":18,"output_tokens":6},"tokens":{"input_tokens":1661,"output_tokens":19}}},"type":"message-end"}
```

**SDK Code**

```typescript Documents
const { CohereClientV2 } = require('cohere-ai');

const cohere = new CohereClientV2({});

(async () => {
  const stream = await cohere.chatStream({
    model: 'command-a-plus-05-2026',
    documents: [
      {
        data: {
          title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters',
          snippet:
            '↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.',
        },
      },
      {
        data: {
          title: 'CSPC: NSYNC Popularity Analysis - ChartMasters',
          snippet:
            "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven't study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn't a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.",
        },
      },
      {
        data: {
          title: 'CSPC: Backstreet Boys Popularity Analysis - ChartMasters',
          snippet:
            " 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women's – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.",
        },
      },
      {
        data: {
          title: 'CSPC: NSYNC Popularity Analysis - ChartMasters',
          snippet:
            " Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I'll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC's albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.",
        },
      },
    ],
    messages: [
      {
        role: 'user',
        content: 'Who is more popular: Nsync or Backstreet Boys?',
      },
    ],
  });

  for await (const chatEvent of stream) {
    console.log(chatEvent);
  }
})();

```

```python Documents
import cohere

co = cohere.ClientV2()

response = co.chat_stream(
    model="command-a-plus-05-2026",
    messages=[{"role": "user", "content": "Who is more popular: Nsync or Backstreet Boys?"}],
    documents=[
        {
            "data":  {
                "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
                "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.",
            }
        },
        {
            "data":  {
                "title": "CSPC: NSYNC Popularity Analysis - ChartMasters",
                "snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven't study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn't a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.",
            }
        },
        {
            "data":  {
                "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
                "snippet": " 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women's – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.",
            }
        },
        {
            "data":  {
                "title": "CSPC: NSYNC Popularity Analysis - ChartMasters",
                "snippet": " Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I'll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC's albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.",
            }
        }
    ],
)

for event in response:
    if event.type == "message-start":
        print("\nMessage started.")
    elif event.type == "message-end":
        print("\nMessage ended.")
    elif event.type == "content-delta":
        print(event.delta.message.content.text, end="")


```

```java Documents
/* (C)2024 */
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatStreamRequest;
import com.cohere.api.resources.v2.types.V2ChatStreamRequestDocumentsItem;
import com.cohere.api.types.*;
import java.util.List;

public class StreamDocuments {
  public static void main(String[] args) {
    Cohere cohere = Cohere.builder().clientName("snippet").build();

    Iterable<StreamedChatResponseV2> response =
        cohere
            .v2()
            .chatStream(
                V2ChatStreamRequest.builder()
                    .model("command-a-plus-05-2026")
                    .messages(
                        List.of(
                            ChatMessageV2.user(
                                UserMessage.builder()
                                    .content(UserMessageContent.of("Who is the most popular?"))
                                    .build())))
                    .documents(
                        List.of(
                            V2ChatStreamRequestDocumentsItem.of(
                                "↓ Skip to Main Content\n\n"
                                    + "Music industry – One step closer to being accurate\n\n"
                                    + "CSPC: Backstreet Boys Popularity Analysis\n\n"
                                    + "At one point, Backstreet Boys defined success: massive album"
                                    + " sales..."),
                            V2ChatStreamRequestDocumentsItem.of(
                                "↓ Skip to Main Content\n\n"
                                    + "CSPC: NSYNC Popularity Analysis\n\n"
                                    + "At the turn of the millennium, three teen acts were huge:"
                                    + " Backstreet Boys, Britney Spears, and NSYNC..."),
                            V2ChatStreamRequestDocumentsItem.of(
                                "Yet the way many music consumers embraced Backstreet Boys deserves"
                                    + " its own chapter..."),
                            V2ChatStreamRequestDocumentsItem.of(
                                "Was NSYNC only successful in the US, or were they a global"
                                    + " phenomenon?...")))
                    .build());

    for (StreamedChatResponseV2 chatResponse : response) {
      if (chatResponse.isContentDelta()) {
        String text =
            chatResponse
                .getContentDelta()
                .flatMap(ChatContentDeltaEvent::getDelta)
                .flatMap(ChatContentDeltaEventDelta::getMessage)
                .flatMap(ChatContentDeltaEventDeltaMessage::getContent)
                .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)
                .orElse("");
        System.out.println(text);
      }
    }
  }
}

```

```go Documents
package main

import (
	"context"
	"errors"
	"io"
	"log"
	"os"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken(os.Getenv("CO_API_KEY")))

	resp, err := co.V2.ChatStream(
		context.TODO(),
		&cohere.V2ChatStreamRequest{
			Model: "command-a-plus-05-2026",
			Documents: []*cohere.V2ChatStreamRequestDocumentsItem{
				{
					Document: &cohere.Document{
						Data: map[string]interface{}{
							"title":   "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
							"snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: Backstreet Boys Popularity Analysis\n\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\n\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\n\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.",
						},
					},
				},
				{
					Document: &cohere.Document{
						Data: map[string]interface{}{
							"title":   "CSPC: NSYNC Popularity Analysis - ChartMasters",
							"snippet": "↓ Skip to Main Content\n\nMusic industry – One step closer to being accurate\n\nCSPC: NSYNC Popularity Analysis\n\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\n\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven't study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\n\nIt wasn't a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.",
						},
					},
				},
				{
					Document: &cohere.Document{
						Data: map[string]interface{}{
							"title":   "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
							"snippet": " 1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\n\nYet the way many music consumers – especially teenagers and young women's – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\n\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.",
						},
					},
				},
				{
					Document: &cohere.Document{
						Data: map[string]interface{}{
							"title":   "CSPC: NSYNC Popularity Analysis - ChartMasters",
							"snippet": " Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\n\nAs usual, I'll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC's albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.",
						},
					},
				},
			},
			Messages: cohere.ChatMessages{
				{
					Role: "user",
					User: &cohere.UserMessageV2{
						Content: &cohere.UserMessageV2Content{
							String: "Who is more popular: Nsync or Backstreet Boys?",
						},
					},
				},
			},
		},
	)

	if err != nil {
		log.Fatal(err)
	}
	defer resp.Close()

	for {
		message, err := resp.Recv()

		if errors.Is(err, io.EOF) {
			// An io.EOF error means the server is done sending messages
			// and should be treated as a success.
			break
		}

		// Log the received message
		if message.ContentDelta != nil {
			log.Printf("%+v", message)
		}
	}
}

```

```ruby Documents
require 'uri'
require 'net/http'

url = URI("https://api.cohere.com/v2/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Who is more popular: Nsync or Backstreet Boys?\"\n    }\n  ],\n  \"documents\": [\n    {\n      \"data\": {\n        \"content\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\",\n        \"snippet\": \"↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: Backstreet Boys Popularity Analysis\\n\\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\\n\\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\\n\\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\",\n        \"snippet\": \"↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: NSYNC Popularity Analysis\\n\\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\\n\\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\\n\\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\",\n        \"snippet\": \"1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\\n\\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\",\n        \"snippet\": \"Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.\"\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```php Documents
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cohere.com/v2/chat', [
  'body' => '{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Who is more popular: Nsync or Backstreet Boys?"
    }
  ],
  "documents": [
    {
      "data": {
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: Backstreet Boys Popularity Analysis\\n\\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\\n\\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\\n\\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak."
      }
    },
    {
      "data": {
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: NSYNC Popularity Analysis\\n\\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N\'Sync\\n\\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\\n\\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold."
      }
    },
    {
      "data": {
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\\n\\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers."
      }
    },
    {
      "data": {
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures."
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Documents
using RestSharp;

var client = new RestClient("https://api.cohere.com/v2/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Who is more popular: Nsync or Backstreet Boys?\"\n    }\n  ],\n  \"documents\": [\n    {\n      \"data\": {\n        \"content\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\",\n        \"snippet\": \"↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: Backstreet Boys Popularity Analysis\\n\\nHernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band\\n\\nAt one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.\\n\\nIt is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\",\n        \"snippet\": \"↓ Skip to Main Content\\n\\nMusic industry – One step closer to being accurate\\n\\nCSPC: NSYNC Popularity Analysis\\n\\nMJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync\\n\\nAt the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.\\n\\nIt wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\",\n        \"snippet\": \"1997, 1998, 2000 and 2001 also rank amongst some of the very best years.\\nYet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.\\n\\nWe will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers.\"\n      }\n    },\n    {\n      \"data\": {\n        \"content\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\",\n        \"snippet\": \"Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?\\nAs usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures.\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Documents
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    [
      "role": "user",
      "content": "Who is more popular: Nsync or Backstreet Boys?"
    ]
  ],
  "documents": [["data": [
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content

Music industry – One step closer to being accurate

CSPC: Backstreet Boys Popularity Analysis

Hernán Lopez Posted on February 9, 2017 Posted in CSPC 72 Comments Tagged with Backstreet Boys, Boy band

At one point, Backstreet Boys defined success: massive albums sales across the globe, great singles sales, plenty of chart topping releases, hugely hyped tours and tremendous media coverage.

It is true that they benefited from extraordinarily good market conditions in all markets. After all, the all-time record year for the music business, as far as revenues in billion dollars are concerned, was actually 1999. That is, back when this five men group was at its peak."
      ]], ["data": [
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "↓ Skip to Main Content

Music industry – One step closer to being accurate

CSPC: NSYNC Popularity Analysis

MJD Posted on February 9, 2018 Posted in CSPC 27 Comments Tagged with Boy band, N'Sync

At the turn of the millennium three teen acts were huge in the US, the Backstreet Boys, Britney Spears and NSYNC. The latter is the only one we haven’t study so far. It took 15 years and Adele to break their record of 2,4 million units sold of No Strings Attached in its first week alone.

It wasn’t a fluke, as the second fastest selling album of the Soundscan era prior 2015, was also theirs since Celebrity debuted with 1,88 million units sold."
      ]], ["data": [
        "content": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters",
        "snippet": "1997, 1998, 2000 and 2001 also rank amongst some of the very best years.
Yet the way many music consumers – especially teenagers and young women’s – embraced their output deserves its own chapter. If Jonas Brothers and more recently One Direction reached a great level of popularity during the past decade, the type of success achieved by Backstreet Boys is in a completely different level as they really dominated the business for a few years all over the world, including in some countries that were traditionally hard to penetrate for Western artists.

We will try to analyze the extent of that hegemony with this new article with final results which will more than surprise many readers."
      ]], ["data": [
        "content": "CSPC: NSYNC Popularity Analysis - ChartMasters",
        "snippet": "Was the teen group led by Justin Timberlake really that big? Was it only in the US where they found success? Or were they a global phenomenon?
As usual, I’ll be using the Commensurate Sales to Popularity Concept in order to relevantly gauge their results. This concept will not only bring you sales information for all NSYNC‘s albums, physical and download singles, as well as audio and video streaming, but it will also determine their true popularity. If you are not yet familiar with the CSPC method, the next page explains it with a short video. I fully recommend watching the video before getting into the sales figures."
      ]]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v2/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Tools

**Request**

```json
{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "query_daily_sales_report",
        "parameters": {
          "properties": {
            "day": {
              "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day."
      }
    },
    {
      "type": "function",
      "function": {
        "name": "query_product_catalog",
        "parameters": {
          "properties": {
            "category": {
              "description": "Retrieves product information data for all products in this category.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "description": "Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels."
      }
    }
  ]
}
```

**Response**

```text
event: message-start
data: {"delta":{"message":{"role":"assistant"}},"id":"2edfdf70-019c-4f7a-be20-3cdbfaa3dca6","type":"message-start"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"I"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" will"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" use"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" query"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"_"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"daily"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"_"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"sales"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"_"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"report"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" tool"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" to"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" find"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" sales"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" summary"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" for"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" 2"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"9"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"th"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" September"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" 2"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"0"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"2"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"3"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"."}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" I"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" will"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" also"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" use"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" query"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"_"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"product"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"_"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"catalog"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" tool"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" to"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" find"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" details"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" of"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" products"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" in"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" the"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" Electronics"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":" category"}},"type":"tool-plan-delta"}

event: tool-plan-delta
data: {"delta":{"message":{"tool_plan":"."}},"type":"tool-plan-delta"}

event: tool-call-start
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"","name":"query_daily_sales_report"},"id":"query_daily_sales_report_j3f0adww9pmr","type":"function"}}},"index":0,"type":"tool-call-start"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"{\""}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"day"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\": "}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\""}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"2"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"0"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"2"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"3"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"-"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"0"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"9"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"-"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"2"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"9"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\"}"}}}},"index":0,"type":"tool-call-delta"}

event: tool-call-end
data: {"index":0,"type":"tool-call-end"}

event: tool-call-start
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"","name":"query_product_catalog"},"id":"query_product_catalog_c66nf11r6s8g","type":"function"}}},"index":1,"type":"tool-call-start"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"{\""}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"category"}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\": "}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\""}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"Electron"}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"ics"}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-delta
data: {"delta":{"message":{"tool_calls":{"function":{"arguments":"\"}"}}}},"index":1,"type":"tool-call-delta"}

event: tool-call-end
data: {"index":1,"type":"tool-call-end"}

event: message-end
data: {"delta":{"finish_reason":"TOOL_CALL","usage":{"billed_units":{"input_tokens":126,"output_tokens":84},"tokens":{"input_tokens":1589,"output_tokens":135}}},"type":"message-end"}
```

**SDK Code**

```typescript Tools
const { CohereClientV2 } = require('cohere-ai');

const cohere = new CohereClientV2({});

(async () => {
  const stream = await cohere.chatStream({
    model: 'command-a-plus-05-2026',
    messages: [
      {
        role: 'user',
        content:
          "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?",
      },
    ],
    tools: [
      {
        type: 'function',
        function: {
          name: 'query_daily_sales_report',
          description:
            'Connects to a database to retrieve overall sales volumes and sales information for a given day.',
          parameters: {
            type: 'object',
            properties: {
              day: {
                description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.',
                type: 'string',
              },
            },
            required: ['day'],
          },
        },
      },
      {
        type: 'function',
        function: {
          name: 'query_product_catalog',
          description:
            'Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels.',
          parameters: {
            type: 'object',
            properties: {
              category: {
                description:
                  'Retrieves product information data for all products in this category.',
                type: 'string',
              },
            },
            required: ['category'],
          },
        },
      },
    ],
  });

  for await (const chatEvent of stream) {
    if (chatEvent.type === 'tool-call-delta') {
      console.log(chatEvent.delta?.message);
    }
  }
})();

```

```python Tools
import cohere

co = cohere.ClientV2()

response = co.chat_stream(
    model="command-a-plus-05-2026",
    messages=[
        {
            "role": "user",
            "content": "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?",
        }
    ],
    tools=[
        cohere.ToolV2(
            type="function",
            function={
                "name": "query_daily_sales_report",
                "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "day": {
                            "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
                            "type": "string",
                        }
                    },
                    "required": ["day"],
                },
            },
        ),
        cohere.ToolV2(
            type="function",
            function={
                "name": "query_product_catalog",
                "description": "Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "category": {
                            "description": "Retrieves product information data for all products in this category.",
                            "type": "string",
                        }
                    },
                    "required": ["category"],
                },
            },
        ),
    ],
)

for event in response:
    if event.type in ["tool-call-start", "tool-call-delta"]:
        for tool_call in event.delta.message.tool_calls:
            print(tool_call)

```

```java Tools
/* (C)2024 */
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatStreamRequest;
import com.cohere.api.types.*;
import java.util.List;
import java.util.Map;

public class StreamTools {
  public static void main(String[] args) {
    Cohere cohere = Cohere.builder().clientName("snippet").build();

    Iterable<StreamedChatResponseV2> response =
        cohere
            .v2()
            .chatStream(
                V2ChatStreamRequest.builder()
                    .model("command-a-plus-05-2026")
                    .tools(
                        List.of(
                            ToolV2.builder()
                                .function(
                                    ToolV2Function.builder()
                                        .name("query_daily_sales_report")
                                        .description(
                                            "Connects to a database to retrieve overall sales"
                                                + " volumes and sales information for a given day.")
                                        .parameters(
                                            Map.of(
                                                "day",
                                                ToolParameterDefinitionsValue.builder()
                                                    .type("str")
                                                    .description(
                                                        "Retrieves sales data for this day,"
                                                            + " formatted as YYYY-MM-DD.")
                                                    .required(true)
                                                    .build()))
                                        .build())
                                .build(),
                            ToolV2.builder()
                                .function(
                                    ToolV2Function.builder()
                                        .name("query_product_catalog")
                                        .description(
                                            "Connects to a product catalog with information about"
                                                + " all the products being sold, including"
                                                + " categories, prices, and stock levels.")
                                        .parameters(
                                            Map.of(
                                                "category",
                                                ToolParameterDefinitionsValue.builder()
                                                    .type("str")
                                                    .description(
                                                        "Retrieves product information data for all"
                                                            + " products in this category.")
                                                    .required(true)
                                                    .build()))
                                        .build())
                                .build()))
                    .messages(
                        List.of(
                            ChatMessageV2.user(
                                UserMessage.builder()
                                    .content(
                                        UserMessageContent.of(
                                            "Can you provide a sales summary for 29th September"
                                                + " 2023, and also give me some details about the"
                                                + " products in the 'Electronics' category?"))
                                    .build())))
                    .build());

    for (StreamedChatResponseV2 chatResponse : response) {
      if (chatResponse.isContentDelta()) {
        String text =
            chatResponse
                .getContentDelta()
                .flatMap(ChatContentDeltaEvent::getDelta)
                .flatMap(ChatContentDeltaEventDelta::getMessage)
                .flatMap(ChatContentDeltaEventDeltaMessage::getContent)
                .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)
                .orElse("");
        System.out.println(text);
      }
    }
  }
}

```

```go Tools
package main

import (
	"context"
	"errors"
	"io"
	"log"
	"os"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken(os.Getenv("CO_API_KEY")))

	resp, err := co.V2.ChatStream(
		context.TODO(),
		&cohere.V2ChatStreamRequest{
			Model: "command-a-plus-05-2026",
			Messages: cohere.ChatMessages{
				{
					Role: "user",
					User: &cohere.UserMessageV2{
						Content: &cohere.UserMessageV2Content{
							String: "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?",
						},
					},
				},
			},
			Tools: []*cohere.ToolV2{
				{
					Function: &cohere.ToolV2Function{
						Name:        "query_daily_sales_report",
						Description: cohere.String("Connects to a database to retrieve overall sales volumes and sales information for a given day."),
						Parameters: map[string]interface{}{
							"type": "object",
							"properties": map[string]interface{}{
								"day": map[string]interface{}{
									"type":        "string",
									"description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
								},
							},
							"required": []string{"day"},
						},
					},
				},
				{
					Function: &cohere.ToolV2Function{
						Name:        "query_product_catalog",
						Description: cohere.String("Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels."),
						Parameters: map[string]interface{}{
							"type": "object",
							"properties": map[string]interface{}{
								"category": map[string]interface{}{
									"type":        "string",
									"description": "Retrieves product information data for all products in this category.",
								},
							},
							"required": []string{"category"},
						},
					},
				},
			},
		},
	)

	if err != nil {
		log.Fatal(err)
	}

	// Make sure to close the stream when you're done reading.
	// This is easily handled with defer.
	defer resp.Close()

	for {
		message, err := resp.Recv()

		if errors.Is(err, io.EOF) {
			// An io.EOF error means the server is done sending messages
			// and should be treated as a success.
			break
		}

		// Log the received message
		if message.ToolCallDelta != nil {
			log.Printf("%+v", message)
		}
	}
}

```

```ruby Tools
require 'uri'
require 'net/http'

url = URI("https://api.cohere.com/v2/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?\"\n    }\n  ],\n  \"tools\": [\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"name\": \"query_daily_sales_report\",\n        \"parameters\": {\n          \"properties\": {\n            \"day\": {\n              \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n              \"type\": \"string\"\n            }\n          },\n          \"type\": \"object\"\n        },\n        \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\"\n      }\n    },\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"name\": \"query_product_catalog\",\n        \"parameters\": {\n          \"properties\": {\n            \"category\": {\n              \"description\": \"Retrieves product information data for all products in this category.\",\n              \"type\": \"string\"\n            }\n          },\n          \"type\": \"object\"\n        },\n        \"description\": \"Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels.\"\n      }\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```php Tools
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cohere.com/v2/chat', [
  'body' => '{
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    {
      "role": "user",
      "content": "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the \'Electronics\' category, for example their prices and stock levels?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "query_daily_sales_report",
        "parameters": {
          "properties": {
            "day": {
              "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day."
      }
    },
    {
      "type": "function",
      "function": {
        "name": "query_product_catalog",
        "parameters": {
          "properties": {
            "category": {
              "description": "Retrieves product information data for all products in this category.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "description": "Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels."
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Tools
using RestSharp;

var client = new RestClient("https://api.cohere.com/v2/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"stream\": true,\n  \"model\": \"command-a-plus-05-2026\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?\"\n    }\n  ],\n  \"tools\": [\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"name\": \"query_daily_sales_report\",\n        \"parameters\": {\n          \"properties\": {\n            \"day\": {\n              \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n              \"type\": \"string\"\n            }\n          },\n          \"type\": \"object\"\n        },\n        \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\"\n      }\n    },\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"name\": \"query_product_catalog\",\n        \"parameters\": {\n          \"properties\": {\n            \"category\": {\n              \"description\": \"Retrieves product information data for all products in this category.\",\n              \"type\": \"string\"\n            }\n          },\n          \"type\": \"object\"\n        },\n        \"description\": \"Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels.\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Tools
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "stream": true,
  "model": "command-a-plus-05-2026",
  "messages": [
    [
      "role": "user",
      "content": "Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?"
    ]
  ],
  "tools": [
    [
      "type": "function",
      "function": [
        "name": "query_daily_sales_report",
        "parameters": [
          "properties": ["day": [
              "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
              "type": "string"
            ]],
          "type": "object"
        ],
        "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day."
      ]
    ],
    [
      "type": "function",
      "function": [
        "name": "query_product_catalog",
        "parameters": [
          "properties": ["category": [
              "description": "Retrieves product information data for all products in this category.",
              "type": "string"
            ]],
          "type": "object"
        ],
        "description": "Connects to a product catalog with information about all the products being sold, including categories, prices, and stock levels."
      ]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v2/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Images

**Request**

```json
{
  "stream": true,
  "model": "command-a-vision-07-2025",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "text": "Describe this image",
          "type": "text"
        },
        {
          "image_url": {
            "detail": "auto",
            "url": "https://cohere.com/favicon-32x32.png"
          },
          "type": "image_url"
        }
      ]
    }
  ]
}
```

**Response**

```text
event: message-start
data: {"delta":{"message":{"role":"assistant"}},"id":"29f14a5a-11de-4cae-9800-25e4747408ea","type":"message-start"}

event: content-start
data: {"delta":{"message":{"content":{"text":"","type":"text"}}},"type":"content-start"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"The"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" image"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" you"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"'ve"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" provided"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" appears"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" to"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" be"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" simple"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" abstract"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" composition"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" featuring"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" three"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" colored"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" shapes"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" on"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" white"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" background"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" At"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" the"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" top"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" there"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"'s"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" large"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" dark"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" green"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" oval"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" shape"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" Below"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" it"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" on"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" the"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" left"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" side"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" there"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"'s"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" smaller"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" bright"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" orange"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" circular"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" shape"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" To"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" the"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" right"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" of"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" the"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" orange"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" circle"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" there"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"'s"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" medium"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"-"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"sized"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":","}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" light"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" purple"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" oval"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" shape"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" The"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" shapes"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" are"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" arranged"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" in"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" somewhat"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" triangular"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" formation"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" The"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" overall"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" style"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" is"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" minimalistic"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" and"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" could"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" be"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" interpreted"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" as"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" form"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" of"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" modern"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" art"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" or"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" a"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" basic"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" design"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":" element"}}},"type":"content-delta"}

event: content-delta
data: {"delta":{"message":{"content":{"text":"."}}},"type":"content-delta"}

event: content-end
data: {"type":"content-end"}

event: message-end
data: {"delta":{"finish_reason":"COMPLETE","usage":{"billed_units":{"input_tokens":262,"output_tokens":105},"tokens":{"input_tokens":499,"output_tokens":105}}},"type":"message-end"}
```

**SDK Code**

```typescript Images
const { CohereClientV2 } = require('cohere-ai');

const cohere = new CohereClientV2({});

(async () => {
  const stream = await cohere.chatStream({
    model: 'command-a-vision-07-2025',
    messages: [
      {
        role: 'user',
        content: [
          { type: 'text', text: 'Describe this image' },
          {
            type: 'image_url',
            imageUrl: {
              // Can be either a base64 data URI or a web URL.
              url: 'https://cohere.com/favicon-32x32.png',
              detail: 'auto',
            },
          },
        ],
      },
    ],
  });

  for await (const chatEvent of stream) {
    if (chatEvent.type === 'content-delta') {
      console.log(chatEvent.delta?.message);
    }
  }
})();

```

```python Images
import cohere

co = cohere.ClientV2()

response = co.chat_stream(
    model="command-a-vision-07-2025",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Describe this image"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        # Can be either a base64 data URI or a web URL.
                        "url": "https://cohere.com/favicon-32x32.png",
                        "detail": "auto"
                    }
                }
            ]
        }
    ]
)

for event in response:
    if event.type == "content-delta":
        print(event.delta.message.content.text, end="")
```

```java Images
/* (C)2024 */
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatStreamRequest;
import com.cohere.api.types.*;
import java.util.List;

public class Stream {
  public static void main(String[] args) {
    Cohere cohere = Cohere.builder().clientName("snippet").build();

    Iterable<StreamedChatResponseV2> response =
        cohere
            .v2()
            .chatStream(
                V2ChatStreamRequest.builder()
                    .model("command-a-vision-07-2025")
                    .messages(
                        List.of(
                            ChatMessageV2.user(
                                UserMessage.builder()
                                    .content(
                                        UserMessageContent.of(
                                            List.of(
                                                Content.text(
                                                    TextContent.builder()
                                                        .text("Describe this image")
                                                        .build()),
                                                Content.imageUrl(
                                                    ImageContent.builder()
                                                        .imageUrl(
                                                            ImageUrl.builder()
                                                                // Can be either a base64 data URI or a web URL.
                                                                .url(
                                                                    "https://cohere.com/favicon-32x32.png")
                                                                .build())
                                                        .build()))))
                                    .build())))
                    .build());

    for (StreamedChatResponseV2 chatResponse : response) {
      if (chatResponse.isContentDelta()) {
        System.out.println(
            chatResponse
                .getContentDelta()
                .flatMap(ChatContentDeltaEvent::getDelta)
                .flatMap(ChatContentDeltaEventDelta::getMessage)
                .flatMap(ChatContentDeltaEventDeltaMessage::getContent)
                .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)
                .orElse(""));
      }
    }

    System.out.println(response);
  }
}

```

```go Images
package main

import (
	"context"
	"errors"
	"io"
	"log"
	"os"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken(os.Getenv("CO_API_KEY")))

	resp, err := co.V2.ChatStream(
		context.TODO(),
		&cohere.V2ChatStreamRequest{
			Model: "command-a-vision-07-2025",
			Messages: cohere.ChatMessages{
				{
					Role: "user",
					User: &cohere.UserMessageV2{
						Content: &cohere.UserMessageV2Content{
							ContentList: []*cohere.Content{
								{Type: "text", Text: &cohere.ChatTextContent{Text: "Describe this image"}},
								{Type: "image_url", ImageUrl: &cohere.ImageContent{
									ImageUrl: &cohere.ImageUrl{
										// Can be either a base64 data URI or a web URL.
										Url:    "https://cohere.com/favicon-32x32.png",
										Detail: cohere.ImageUrlDetailAuto.Ptr(),
									},
								}},
							},
						},
					},
				},
			},
		},
	)

	if err != nil {
		log.Fatal(err)
	}

	// Make sure to close the stream when you're done reading.
	// This is easily handled with defer.
	defer resp.Close()

	for {
		message, err := resp.Recv()

		if errors.Is(err, io.EOF) {
			// An io.EOF error means the server is done sending messages
			// and should be treated as a success.
			break
		}

		if message.ContentDelta != nil {
			log.Printf("%+v", message)
		}
	}
}

```

```ruby Images
require 'uri'
require 'net/http'

url = URI("https://api.cohere.com/v2/chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"stream\": true,\n  \"model\": \"command-a-vision-07-2025\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"text\": \"Describe this image\",\n          \"type\": \"text\"\n        },\n        {\n          \"image_url\": {\n            \"detail\": \"auto\",\n            \"url\": \"https://cohere.com/favicon-32x32.png\"\n          },\n          \"type\": \"image_url\"\n        }\n      ]\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```php Images
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cohere.com/v2/chat', [
  'body' => '{
  "stream": true,
  "model": "command-a-vision-07-2025",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "text": "Describe this image",
          "type": "text"
        },
        {
          "image_url": {
            "detail": "auto",
            "url": "https://cohere.com/favicon-32x32.png"
          },
          "type": "image_url"
        }
      ]
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Images
using RestSharp;

var client = new RestClient("https://api.cohere.com/v2/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"stream\": true,\n  \"model\": \"command-a-vision-07-2025\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": [\n        {\n          \"text\": \"Describe this image\",\n          \"type\": \"text\"\n        },\n        {\n          \"image_url\": {\n            \"detail\": \"auto\",\n            \"url\": \"https://cohere.com/favicon-32x32.png\"\n          },\n          \"type\": \"image_url\"\n        }\n      ]\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Images
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "stream": true,
  "model": "command-a-vision-07-2025",
  "messages": [
    [
      "role": "user",
      "content": [
        [
          "text": "Describe this image",
          "type": "text"
        ],
        [
          "image_url": [
            "detail": "auto",
            "url": "https://cohere.com/favicon-32x32.png"
          ],
          "type": "image_url"
        ]
      ]
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v2/chat")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```