> 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 (V1)

POST https://api.cohere.com/v1/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/docs/chat-api).


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

## 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.
- `Accepts` (enum, optional) — Pass text/event-stream to receive the streamed response as server-sent events. The default is `\n` delimited events.
  - Allowed values: `text/event-stream`

### Body (application/json)

This endpoint expects an object.

- `message` (string, required) — Text input for the model to respond to. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `stream` (false, required) — Defaults to `false`. When `true`, the response will be a JSON stream of events. The final event will contain the complete response, and will have an `event_type` of `"stream-end"`. Streaming is beneficial for user interfaces that render the contents of the response piece by piece, as it gets generated. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `model` (string, optional) — The name of a compatible [Cohere model](https://docs.cohere.com/docs/models) or the ID of a [fine-tuned](https://docs.cohere.com/docs/chat-fine-tuning) model. Compatible Deployments: Cohere Platform, Private Deployments
- `preamble` (string, optional) — When specified, the default Cohere preamble will be replaced with the provided one. Preambles are a part of the prompt used to adjust the model's overall behavior and conversation style, and use the `SYSTEM` role. The `SYSTEM` role is also used for the contents of the optional `chat_history=` parameter. When used with the `chat_history=` parameter it adds content throughout a conversation. Conversely, when used with the `preamble=` parameter it adds content at the start of the conversation only. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `chat_history` (list of Message, optional) — A list of previous messages between the user and the model, giving the model conversational context for responding to the user's `message`. Each item represents a single message in the chat history, excluding the current user turn. It has two properties: `role` and `message`. The `role` identifies the sender (`CHATBOT`, `SYSTEM`, or `USER`), while the `message` contains the text content. The chat_history parameter should not be used for `SYSTEM` messages in most cases. Instead, to add a `SYSTEM` role message at the beginning of a conversation, the `preamble` parameter should be used. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `conversation_id` (string, optional) — An alternative to `chat_history`. Providing a `conversation_id` creates or resumes a persisted conversation with the specified ID. The ID can be any non empty string. Compatible Deployments: Cohere Platform
- `prompt_truncation` (enum, optional) — Defaults to `AUTO` when `connectors` are specified and `OFF` in all other cases. Dictates how the prompt will be constructed. With `prompt_truncation` set to "AUTO", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be changed and ranked by relevance. With `prompt_truncation` set to "AUTO_PRESERVE_ORDER", some elements from `chat_history` and `documents` will be dropped in an attempt to construct a prompt that fits within the model's context length limit. During this process the order of the documents and chat history will be preserved as they are inputted into the API. With `prompt_truncation` set to "OFF", no elements will be dropped. If the sum of the inputs exceeds the model's context length limit, a `TooManyTokens` error will be returned. Compatible Deployments: - AUTO: Cohere Platform Only - AUTO_PRESERVE_ORDER: Azure, AWS Sagemaker/Bedrock, Private Deployments
  - Allowed values: `OFF`, `AUTO`, `AUTO_PRESERVE_ORDER`
- `documents` (list of map from string to string, optional) — A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. Example: ``` [ { "title": "Tall penguins", "text": "Emperor penguins are the tallest." }, { "title": "Penguin habitats", "text": "Emperor penguins only live in Antarctica." }, ] ``` Keys and values from each document will be serialized to a string and passed to the model. The resulting generation will include citations that reference some of these documents. Some suggested keys are "text", "author", and "date". For better generation quality, it is recommended to keep the total word count of the strings in the dictionary to under 300 words. An `id` field (string) can be optionally supplied to identify the document in the citations. This field will not be passed to the model. An `_excludes` field (array of strings) can be optionally supplied to omit some key-value pairs from being shown to the model. The omitted fields will still show up in the citation object. The "\_excludes" field will not be passed to the model. See ['Document Mode'](https://docs.cohere.com/docs/retrieval-augmented-generation-rag#document-mode) in the guide for more information. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `citation_quality` (enum, optional) — Defaults to `"enabled"`. Citations are enabled by default for models that support it, but can be turned off by setting `"type": "disabled"`. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
  - Allowed values: `ENABLED`, `DISABLED`, `FAST`, `ACCURATE`, `OFF`
- `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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `max_tokens` (integer, optional) — The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `max_input_tokens` (integer, optional) — The maximum number of input tokens to send to the model. If not specified, `max_input_tokens` is the model's context length limit minus a small buffer. Input will be truncated according to the `prompt_truncation` parameter. Compatible Deployments: Cohere Platform
- `k` (integer, optional, default: 0) — Ensures only the top `k` most likely tokens are considered for generation at each step. Defaults to `0`, min value of `0`, max value of `500`. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `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`. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `raw_prompting` (boolean, optional) — When enabled, the user's prompt will be sent to the model without any pre-processing. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `tools` (list of Tool, optional) — A list of available tools (functions) that the model may suggest invoking before producing a text response. When `tools` is passed (without `tool_results`), the `text` field in the response will be `""` and the `tool_calls` field in the response will be populated with a list of tool calls that need to be made. If no calls need to be made, the `tool_calls` array will be empty. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `tool_results` (list of ToolResult, optional) — A list of results from invoking tools recommended by the model in the previous chat turn. Results are used to produce a text response and will be referenced in citations. When using `tool_results`, `tools` must be passed as well. Each tool\_result contains information about how it was invoked, as well as a list of outputs in the form of dictionaries. **Note**: `outputs` must be a list of objects. If your tool returns a single object (eg `{"status": 200}`), make sure to wrap it in a list. ``` tool_results = [ { "call": { "name": <tool name>, "parameters": { <param name>: <param value> } }, "outputs": [{ <key>: <value> }] }, ... ] ``` **Note**: Chat calls with `tool_results` should not be included in the Chat history to avoid duplication of the message text. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
- `force_single_step` (boolean, optional) — Forces the chat to be single step. Defaults to `false`.
- `response_format` (ResponseFormat, optional) — Configuration for forcing the model output to adhere to the specified format. Supported on [Command R 03-2024](https://docs.cohere.com/docs/command-r), [Command R+ 04-2024](https://docs.cohere.com/docs/command-r-plus) and newer models. The model can be forced into outputting JSON objects (with up to 5 levels of nesting) 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. **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided).
- `safety_mode` (enum, optional) — Used to select the [safety instruction](https://docs.cohere.com/docs/safety-modes) inserted into the prompt. Defaults to `CONTEXTUAL`. When `NONE` is specified, the safety instruction will be omitted. Safety modes are not yet configurable in combination with `tools`, `tool_results` 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. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
  - Allowed values: `CONTEXTUAL`, `STRICT`, `NONE`
- `connectors` (list of ChatConnector, optional, deprecated) — Accepts `{"id": "web-search"}`, and/or the `"id"` for a custom [connector](https://docs.cohere.com/docs/connectors), if you've [created](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) one. When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). Compatible Deployments: Cohere Platform
- `search_queries_only` (boolean, optional, deprecated) — Defaults to `false`. When `true`, the response will only contain a list of generated search queries, but no search will take place, and no reply from the model to the user's `message` will be generated. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments

## Response

### 200

- `text` (string, required) — Contents of the reply generated by the model.
- `generation_id` (string, optional) — Unique identifier for the generated reply. Useful for submitting feedback.
- `response_id` (string, optional) — Unique identifier for the response.
- `citations` (list of ChatCitation, optional) — Inline citations for the generated reply.
- `documents` (list of map from string to string, optional) — Documents seen by the model when generating the reply.
- `is_search_required` (boolean, optional) — Denotes that a search for documents is required during the RAG flow.
- `search_queries` (list of ChatSearchQuery, optional) — Generated search queries, meant to be used as part of the RAG flow.
- `search_results` (list of ChatSearchResult, optional) — Documents retrieved from each of the conducted searches.
- `finish_reason` (enum, optional)
  - Allowed values: `COMPLETE`, `STOP_SEQUENCE`, `ERROR`, `ERROR_TOXIC`, `ERROR_LIMIT`, `USER_CANCEL`, `MAX_TOKENS`, `TIMEOUT`
- `tool_calls` (list of ToolCall, optional)
- `chat_history` (list of Message, optional) — A list of previous messages between the user and the model, meant to give the model conversational context for responding to the user's `message`.
- `meta` (ApiMeta, 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

### Message

- `role`: `CHATBOT` (CHATBOT)
  - `message` (string, required) — Contents of the chat message.
  - `tool_calls` (list of ToolCall, optional)
- `role`: `SYSTEM` (SYSTEM)
  - `message` (string, required) — Contents of the chat message.
  - `tool_calls` (list of ToolCall, optional)
- `role`: `USER` (USER)
  - `message` (string, required) — Contents of the chat message.
  - `tool_calls` (list of ToolCall, optional)
- `role`: `TOOL` (TOOL)
  - `tool_results` (list of ToolResult, optional)

### Tool

- `name` (string, required) — The name of the tool to be called. Valid names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit.
- `description` (string, required) — The description of what the tool does, the model uses the description to choose when and how to call the function.
- `parameter_definitions` (map from string to ToolParameterDefinitions, optional) — The input parameters of the tool. Accepts a dictionary where the key is the name of the parameter and the value is the parameter spec. Valid parameter names contain only the characters `a-z`, `A-Z`, `0-9`, `_` and must not begin with a digit. ``` { "my_param": { "description": <string>, "type": <string>, // any python data type, such as 'str', 'bool' "required": <boolean> } } ```

### ToolResult

- `call` (ToolCall, required) — Contains the tool calls generated by the model. Use it to invoke your tools.
- `outputs` (list of map from string to any, required)

### ResponseFormat

Configuration for forcing the model output to adhere to the specified format. Supported on [Command R 03-2024](https://docs.cohere.com/docs/command-r), [Command R+ 04-2024](https://docs.cohere.com/docs/command-r-plus) and newer models. The model can be forced into outputting JSON objects (with up to 5 levels of nesting) 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. **Limitation**: The parameter is not supported in RAG mode (when any of `connectors`, `documents`, `tools`, `tool_results` are provided).

- `type`: `text` (Text Response)
- `type`: `json_object` (JSON Object Response)
  - `schema` (JSONResponseFormat-g7xopi, optional) — A JSON schema 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"`.

### ChatConnector

The connector used for fetching documents.

- `id` (string, required) — The identifier of the connector.
- `user_access_token` (string, optional) — When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one.
- `continue_on_failure` (boolean, optional) — Defaults to `false`. When `true`, the request will continue if this connector returned an error.
- `options` (ChatConnector-7ur0eu, optional) — Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector. For example, the connector `web-search` supports the `site` option, which limits search results to the specified domain.

### ChatCitation

A section of the generated reply which cites external knowledge.

- `start` (integer, required) — The index of text that the citation starts at, counting from zero. For example, a generation of `Hello, world!` with a citation on `world` would have a start value of `7`. This is because the citation starts at `w`, which is the seventh character.
- `end` (integer, required) — The index of text that the citation ends after, counting from zero. For example, a generation of `Hello, world!` with a citation on `world` would have an end value of `11`. This is because the citation ends after `d`, which is the eleventh character.
- `text` (string, required) — The text of the citation. For example, a generation of `Hello, world!` with a citation of `world` would have a text value of `world`.
- `document_ids` (list of string, required) — Identifiers of documents cited by this section of the generated reply.
- `type` (enum, optional) — The type of citation which indicates what part of the response the citation is for.
  - Allowed values: `TEXT_CONTENT`, `PLAN`

### ChatSearchQuery

The generated search query. Contains the text of the query and a unique identifier for the query.

- `text` (string, required) — The text of the search query.
- `generation_id` (string, required) — Unique identifier for the generated search query. Useful for submitting feedback.

### ChatSearchResult

- `connector` (ChatSearchResultConnector, required) — The connector from which this result comes from.
- `document_ids` (list of string, required) — Identifiers of documents found by this search query.
- `search_query` (ChatSearchQuery, optional) — The generated search query. Contains the text of the query and a unique identifier for the query.
- `error_message` (string, optional) — An error message if the search failed.
- `continue_on_failure` (boolean, optional) — Whether a chat request should continue or not if the request to this connector fails.

### ToolCall

Contains the tool calls generated by the model. Use it to invoke your tools.

- `name` (string, required) — Name of the tool to call.
- `parameters` (map from string to any, required) — The name and value of the parameters to use when invoking a tool.

### ApiMeta

- `api_version` (ApiMetaApiVersion, optional)
- `billed_units` (ApiMetaBilledUnits, optional)
- `tokens` (ApiMetaTokens, optional)
- `cached_tokens` (double, optional) — The number of prompt tokens that hit the inference cache.
- `warnings` (list of string, optional)

### ToolParameterDefinitions

- `type` (string, required) — The type of the parameter. Must be a valid Python type.
- `description` (string, optional) — The description of the parameter.
- `required` (boolean, optional, default: false) — Denotes whether the parameter is always present (required) or not. Defaults to not required.

### JSONResponseFormat-g7xopi

A JSON schema 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"`.

### ChatConnector-7ur0eu

Provides the connector with different settings at request time. The key/value pairs of this object are specific to each connector. For example, the connector `web-search` supports the `site` option, which limits search results to the specified domain.

### ChatSearchResultConnector

The connector used for fetching documents.

- `id` (string, required) — The identifier of the connector.

### ApiMetaApiVersion

- `version` (string, required)
- `is_deprecated` (boolean, optional)
- `is_experimental` (boolean, optional)

### ApiMetaBilledUnits

- `images` (double, optional) — The number of billed images.
- `input_tokens` (double, optional) — The number of billed input tokens.
- `image_tokens` (double, optional) — The number of billed image 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.
- `pages` (double, optional) — The number of billed pages parsed.

### ApiMetaTokens

- `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.

## Examples

### Default

**Request**

```json
{
  "message": "Tell me about LLMs",
  "stream": false,
  "model": "command-a-03-2025"
}
```

**Response**

```json
{
  "text": "Large Language Models (LLMs) are advanced AI systems trained on vast amounts of text data to understand and generate human-like text. They use deep learning architectures, particularly transformers, to process and produce language.\n\nKey characteristics of LLMs include:\n\n1. **Scale**: They're trained on billions or trillions of parameters, making them capable of understanding complex patterns in language.\n\n2. **Versatility**: LLMs can perform various tasks like translation, summarization, question answering, and creative writing without being explicitly programmed for each task.\n\n3. **Context Understanding**: They can maintain context over long conversations and generate coherent, contextually relevant responses.\n\n4. **Few-shot Learning**: LLMs can often perform new tasks with just a few examples, adapting to new scenarios quickly.\n\nPopular examples include GPT (Generative Pre-trained Transformer) models, BERT, and Cohere's Command models. These models have revolutionized natural language processing and enabled new applications across industries.",
  "generation_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "finish_reason": "COMPLETE",
  "chat_history": [
    {
      "role": "USER",
      "message": "Tell me about LLMs"
    },
    {
      "role": "CHATBOT",
      "message": "Large Language Models (LLMs) are advanced AI systems trained on vast amounts of text data to understand and generate human-like text. They use deep learning architectures, particularly transformers, to process and produce language.\n\nKey characteristics of LLMs include:\n\n1. **Scale**: They're trained on billions or trillions of parameters, making them capable of understanding complex patterns in language.\n\n2. **Versatility**: LLMs can perform various tasks like translation, summarization, question answering, and creative writing without being explicitly programmed for each task.\n\n3. **Context Understanding**: They can maintain context over long conversations and generate coherent, contextually relevant responses.\n\n4. **Few-shot Learning**: LLMs can often perform new tasks with just a few examples, adapting to new scenarios quickly.\n\nPopular examples include GPT (Generative Pre-trained Transformer) models, BERT, and Cohere's Command models. These models have revolutionized natural language processing and enabled new applications across industries."
    }
  ],
  "meta": {
    "api_version": {
      "version": "1"
    },
    "billed_units": {
      "input_tokens": 5,
      "output_tokens": 198
    },
    "tokens": {
      "input_tokens": 71,
      "output_tokens": 198
    }
  }
}
```

**SDK Code**

```go Default
package main

import (
	"context"
	"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.Chat(
		context.TODO(),
		&cohere.ChatRequest{
			Model:   cohere.String("command-a-03-2025"),
			Message: "Tell me about LLMs",
		},
	)

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

	log.Printf("%+v", resp)
}

```

```typescript Default
import { CohereClient } from 'cohere-ai';

const cohere = new CohereClient({});

(async () => {
  const response = await cohere.chat({
    model: 'command-a-03-2025',
    message: 'Tell me about LLMs',
  });

  console.log(response);
})();

```

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

import com.cohere.api.Cohere;
import com.cohere.api.requests.ChatRequest;
import com.cohere.api.types.ChatMessage;
import com.cohere.api.types.Message;
import com.cohere.api.types.NonStreamedChatResponse;
import java.util.List;

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

    NonStreamedChatResponse response =
        cohere.chat(
            ChatRequest.builder()
                .model("command-a-03-2025")
                .message("Tell me about LLMs")
                .build());

    System.out.println(response);
  }
}

```

```python Sync
import cohere

co = cohere.Client()

response = co.chat(
    model="command-a-03-2025",
    message="Tell me about LLMs",
)

print(response)

```

```python Async
import cohere
import asyncio

co = cohere.AsyncClient()


async def main():
    return await co.chat(
        model="command-a-03-2025",
        message="Tell me about LLMs"
    )


asyncio.run(main())

```

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

url = URI("https://api.cohere.com/v1/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  \"message\": \"Tell me about LLMs\",\n  \"stream\": false,\n  \"model\": \"command-a-03-2025\"\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/v1/chat', [
  'body' => '{
  "message": "Tell me about LLMs",
  "stream": false,
  "model": "command-a-03-2025"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Default
using RestSharp;

var client = new RestClient("https://api.cohere.com/v1/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Tell me about LLMs\",\n  \"stream\": false,\n  \"model\": \"command-a-03-2025\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Default
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "message": "Tell me about LLMs",
  "stream": false,
  "model": "command-a-03-2025"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v1/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
{
  "message": "Who is more popular: Nsync or Backstreet Boys?",
  "stream": false,
  "model": "command-a-03-2025",
  "documents": [
    {
      "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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC 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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC Popularity Analysis - ChartMasters"
    }
  ]
}
```

**Response**

```json
{
  "text": "Both NSync and Backstreet Boys were extremely popular at the turn of the millennium. Backstreet Boys had massive album sales across the globe, great singles sales, plenty of chart-topping releases, hyped tours, and tremendous media coverage. NSync also had huge sales, with their album No Strings Attached selling 2.4 million units in its first week. They also had the second fastest-selling album of the Soundscan era before 2015, with Celebrity debuting at 1.88 million units sold.\n\nWhile it is difficult to say for sure which of the two bands was more popular, Backstreet Boys did have success in some countries that were traditionally hard to penetrate for Western artists.",
  "generation_id": "c14c80c3-18eb-4519-9460-6c92edd8cfb4",
  "citations": [
    {
      "start": 36,
      "end": 84,
      "text": "extremely popular at the turn of the millennium.",
      "document_ids": [
        "doc_1"
      ]
    },
    {
      "start": 105,
      "end": 141,
      "text": "massive album sales across the globe",
      "document_ids": [
        "doc_0"
      ]
    },
    {
      "start": 143,
      "end": 162,
      "text": "great singles sales",
      "document_ids": [
        "doc_0"
      ]
    },
    {
      "start": 164,
      "end": 196,
      "text": "plenty of chart-topping releases",
      "document_ids": [
        "doc_0"
      ]
    },
    {
      "start": 198,
      "end": 209,
      "text": "hyped tours",
      "document_ids": [
        "doc_0"
      ]
    },
    {
      "start": 215,
      "end": 241,
      "text": "tremendous media coverage.",
      "document_ids": [
        "doc_0"
      ]
    },
    {
      "start": 280,
      "end": 350,
      "text": "album No Strings Attached selling 2.4 million units in its first week.",
      "document_ids": [
        "doc_1"
      ]
    },
    {
      "start": 369,
      "end": 430,
      "text": "second fastest-selling album of the Soundscan era before 2015",
      "document_ids": [
        "doc_1"
      ]
    },
    {
      "start": 437,
      "end": 483,
      "text": "Celebrity debuting at 1.88 million units sold.",
      "document_ids": [
        "doc_1"
      ]
    },
    {
      "start": 589,
      "end": 677,
      "text": "success in some countries that were traditionally hard to penetrate for Western artists.",
      "document_ids": [
        "doc_2"
      ]
    }
  ],
  "documents": [
    {
      "id": "doc_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": "doc_0",
      "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.",
      "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters"
    },
    {
      "id": "doc_2",
      "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.",
      "title": "CSPC: Backstreet Boys Popularity Analysis - ChartMasters"
    }
  ],
  "finish_reason": "COMPLETE",
  "chat_history": [
    {
      "role": "USER",
      "message": "Who is more popular: Nsync or Backstreet Boys?"
    },
    {
      "role": "CHATBOT",
      "message": "Both NSync and Backstreet Boys were extremely popular at the turn of the millennium. Backstreet Boys had massive album sales across the globe, great singles sales, plenty of chart-topping releases, hyped tours, and tremendous media coverage. NSync also had huge sales, with their album No Strings Attached selling 2.4 million units in its first week. They also had the second fastest-selling album of the Soundscan era before 2015, with Celebrity debuting at 1.88 million units sold.\n\nWhile it is difficult to say for sure which of the two bands was more popular, Backstreet Boys did have success in some countries that were traditionally hard to penetrate for Western artists."
    }
  ],
  "meta": {
    "api_version": {
      "version": "1"
    },
    "billed_units": {
      "input_tokens": 682,
      "output_tokens": 143
    },
    "tokens": {
      "input_tokens": 1380,
      "output_tokens": 434
    }
  }
}
```

**SDK Code**

```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.ChatStream(
		context.TODO(),
		&cohere.ChatStreamRequest{
			Model:   cohere.String("command-a-03-2025"),
			Message: "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.TextGeneration != nil {
			log.Printf("%+v", resp)
		}
	}

}

```

```typescript Documents
import { CohereClient } from 'cohere-ai';

const cohere = new CohereClient({});

(async () => {
  const response = await cohere.chat({
    model: 'command-a-03-2025',
    message: 'Who is more popular: Nsync or Backstreet Boys?',
    documents: [
      {
        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.',
      },
      {
        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.",
      },
      {
        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.',
      },
      {
        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.',
      },
    ],
  });

  console.log(response);
})();

```

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

import com.cohere.api.Cohere;
import com.cohere.api.requests.ChatRequest;
import com.cohere.api.types.NonStreamedChatResponse;
import java.util.List;
import java.util.Map;

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

    NonStreamedChatResponse response =
        cohere.chat(
            ChatRequest.builder()
                .model("command-a-03-2025")
                .message("What year was he born?")
                .documents(
                    List.of(
                        Map.of(
                            "title",
                                "CSPC: Backstreet Boys Popularity" + " Analysis - ChartMasters",
                            "snippet",
                                "↓ Skip to Main Content\n\n"
                                    + "Music industry – One step"
                                    + " closer to being"
                                    + " accurate\n\n"
                                    + "CSPC: Backstreet Boys"
                                    + " Popularity Analysis\n\n"
                                    + "Hernán Lopez Posted on"
                                    + " February 9, 2017 Posted in"
                                    + " CSPC 72 Comments Tagged"
                                    + " with Backstreet Boys, Boy"
                                    + " band\n\n"
                                    + "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.\n\n"
                                    + "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."),
                        Map.of(
                            "title", "CSPC: NSYNC Popularity Analysis -" + " ChartMasters",
                            "snippet",
                                "↓ Skip to Main Content\n\n"
                                    + "Music industry – One step"
                                    + " closer to being"
                                    + " accurate\n\n"
                                    + "CSPC: NSYNC Popularity"
                                    + " Analysis\n\n"
                                    + "MJD Posted on February 9,"
                                    + " 2018 Posted in CSPC 27"
                                    + " Comments Tagged with Boy"
                                    + " band, N'Sync\n\n"
                                    + "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.\n\n"
                                    + "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."),
                        Map.of(
                            "title",
                                "CSPC: Backstreet Boys Popularity" + " Analysis - ChartMasters",
                            "snippet",
                                " 1997, 1998, 2000 and 2001 also"
                                    + " rank amongst some of the"
                                    + " very best years.\n\n"
                                    + "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.\n\n"
                                    + "We will try to analyze the"
                                    + " extent of that hegemony"
                                    + " with this new article with"
                                    + " final results which will"
                                    + " more than surprise many"
                                    + " readers."),
                        Map.of(
                            "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\n"
                                + "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.")))
                .build());

    System.out.println(response);
  }
}

```

```python Documents
import cohere

co = cohere.Client()

response = co.chat(
    model="command-a-03-2025",
    message="Who is more popular: Nsync or Backstreet Boys?",
    documents=[
        {
            "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.",
        },
        {
            "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.",
        },
        {
            "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.",
        },
        {
            "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.",
        },
    ],
)

print(response)

```

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

url = URI("https://api.cohere.com/v1/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  \"message\": \"Who is more popular: Nsync or Backstreet Boys?\",\n  \"stream\": false,\n  \"model\": \"command-a-03-2025\",\n  \"documents\": [\n    {\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      \"title\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\"\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/v1/chat', [
  'body' => '{
  "message": "Who is more popular: Nsync or Backstreet Boys?",
  "stream": false,
  "model": "command-a-03-2025",
  "documents": [
    {
      "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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC 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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC Popularity Analysis - ChartMasters"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Documents
using RestSharp;

var client = new RestClient("https://api.cohere.com/v1/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"Who is more popular: Nsync or Backstreet Boys?\",\n  \"stream\": false,\n  \"model\": \"command-a-03-2025\",\n  \"documents\": [\n    {\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      \"title\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: Backstreet Boys Popularity Analysis - ChartMasters\"\n    },\n    {\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      \"title\": \"CSPC: NSYNC Popularity Analysis - ChartMasters\"\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 = [
  "message": "Who is more popular: Nsync or Backstreet Boys?",
  "stream": false,
  "model": "command-a-03-2025",
  "documents": [
    [
      "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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC 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.",
      "title": "CSPC: Backstreet Boys 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.",
      "title": "CSPC: NSYNC Popularity Analysis - ChartMasters"
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v1/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
{
  "message": "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?",
  "stream": false,
  "model": "command-a-03-2025",
  "tools": [
    {
      "name": "query_daily_sales_report",
      "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
      "parameter_definitions": {
        "day": {
          "type": "str",
          "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
          "required": true
        }
      }
    },
    {
      "name": "query_product_catalog",
      "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
      "parameter_definitions": {
        "category": {
          "type": "str",
          "description": "Retrieves product information data for all products in this category.",
          "required": true
        }
      }
    }
  ]
}
```

**Response**

```json
{
  "text": "I will first find the sales summary for 29th September 2023. Then, I will find the details of the products in the 'Electronics' category.",
  "generation_id": "9e5f00aa-bf1e-481a-abe3-0eceac18c3ec",
  "finish_reason": "COMPLETE",
  "tool_calls": [
    {
      "name": "query_daily_sales_report",
      "parameters": {
        "day": {}
      }
    },
    {
      "name": "query_product_catalog",
      "parameters": {
        "category": "Electronics"
      }
    }
  ],
  "chat_history": [
    {
      "role": "USER",
      "message": "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?"
    },
    {
      "role": "CHATBOT",
      "message": "I will first find the sales summary for 29th September 2023. Then, I will find the details of the products in the 'Electronics' category.",
      "tool_calls": [
        {
          "name": "query_daily_sales_report",
          "parameters": {
            "day": {}
          }
        },
        {
          "name": "query_product_catalog",
          "parameters": {
            "category": "Electronics"
          }
        }
      ]
    }
  ],
  "meta": {
    "api_version": {
      "version": "1"
    },
    "billed_units": {
      "input_tokens": 127,
      "output_tokens": 69
    },
    "tokens": {
      "input_tokens": 1032,
      "output_tokens": 124
    }
  }
}
```

**SDK Code**

```go Tools
package main

import (
	"context"
	"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.Chat(
		context.TODO(),
		&cohere.ChatRequest{
			Model:   cohere.String("command-a-03-2025"),
			Message: "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.Tool{
				{
					Name:        "query_daily_sales_report",
					Description: "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
					ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{
						"day": {
							Description: cohere.String("Retrieves sales data for this day, formatted as YYYY-MM-DD."),
							Type:        "str",
							Required:    cohere.Bool(true),
						},
					},
				},
				{
					Name:        "query_product_catalog",
					Description: "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
					ParameterDefinitions: map[string]*cohere.ToolParameterDefinitionsValue{
						"category": {
							Description: cohere.String("Retrieves product information data for all products in this category."),
							Type:        "str",
							Required:    cohere.Bool(true),
						},
					},
				},
			},
		},
	)

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

	log.Printf("%+v", resp)
}

```

```typescript Tools
import { CohereClient } from 'cohere-ai';

const cohere = new CohereClient({});

(async () => {
  const response = await cohere.chat({
    model: 'command-a-03-2025',
    message:
      "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: [
      {
        name: 'query_daily_sales_report',
        description:
          'Connects to a database to retrieve overall sales volumes and sales information for a given day.',
        parameterDefinitions: {
          day: {
            description: 'Retrieves sales data for this day, formatted as YYYY-MM-DD.',
            type: 'str',
            required: true,
          },
        },
      },
      {
        name: 'query_product_catalog',
        description:
          'Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.',
        parameterDefinitions: {
          category: {
            description: 'Retrieves product information data for all products in this category.',
            type: 'str',
            required: true,
          },
        },
      },
    ],
  });

  console.log(response);
})();

```

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

import com.cohere.api.Cohere;
import com.cohere.api.requests.ChatRequest;
import com.cohere.api.types.NonStreamedChatResponse;
import com.cohere.api.types.Tool;
import com.cohere.api.types.ToolParameterDefinitionsValue;
import java.util.List;
import java.util.Map;

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

    NonStreamedChatResponse response =
        cohere.chat(
            ChatRequest.builder()
                .model("command-a-03-2025")
                .message(
                    "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(
                    List.of(
                        Tool.builder()
                            .name("query_daily_sales_report")
                            .description(
                                "Connects to a database to retrieve"
                                    + " overall sales volumes and"
                                    + " sales information for a"
                                    + " given day.")
                            .parameterDefinitions(
                                Map.of(
                                    "day",
                                    ToolParameterDefinitionsValue.builder()
                                        .type("str")
                                        .description(
                                            "Retrieves"
                                                + " sales"
                                                + " data"
                                                + " for this"
                                                + " day,"
                                                + " formatted"
                                                + " as YYYY-MM-DD.")
                                        .required(true)
                                        .build()))
                            .build(),
                        Tool.builder()
                            .name("query_product_catalog")
                            .description(
                                "Connects to a a product catalog"
                                    + " with information about all"
                                    + " the products being sold,"
                                    + " including categories,"
                                    + " prices, and stock levels.")
                            .parameterDefinitions(
                                Map.of(
                                    "category",
                                    ToolParameterDefinitionsValue.builder()
                                        .type("str")
                                        .description(
                                            "Retrieves"
                                                + " product"
                                                + " information"
                                                + " data"
                                                + " for all"
                                                + " products"
                                                + " in this"
                                                + " category.")
                                        .required(true)
                                        .build()))
                            .build()))
                .build());

    System.out.println(response);
  }
}

```

```python Tools
import cohere

co = cohere.Client()

# tool descriptions that the model has access to
tools = [
    {
        "name": "query_daily_sales_report",
        "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
        "parameter_definitions": {
            "day": {
                "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
                "type": "str",
                "required": True,
            }
        },
    },
    {
        "name": "query_product_catalog",
        "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
        "parameter_definitions": {
            "category": {
                "description": "Retrieves product information data for all products in this category.",
                "type": "str",
                "required": True,
            }
        },
    },
]


# user request
message = "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?"

response = co.chat(
    model="command-a-03-2025",
    message=message,
    tools=tools,
)

print(response)

```

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

url = URI("https://api.cohere.com/v1/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  \"message\": \"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  \"stream\": false,\n  \"model\": \"command-a-03-2025\",\n  \"tools\": [\n    {\n      \"name\": \"query_daily_sales_report\",\n      \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\",\n      \"parameter_definitions\": {\n        \"day\": {\n          \"type\": \"str\",\n          \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n          \"required\": true\n        }\n      }\n    },\n    {\n      \"name\": \"query_product_catalog\",\n      \"description\": \"Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.\",\n      \"parameter_definitions\": {\n        \"category\": {\n          \"type\": \"str\",\n          \"description\": \"Retrieves product information data for all products in this category.\",\n          \"required\": true\n        }\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/v1/chat', [
  'body' => '{
  "message": "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?",
  "stream": false,
  "model": "command-a-03-2025",
  "tools": [
    {
      "name": "query_daily_sales_report",
      "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
      "parameter_definitions": {
        "day": {
          "type": "str",
          "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
          "required": true
        }
      }
    },
    {
      "name": "query_product_catalog",
      "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
      "parameter_definitions": {
        "category": {
          "type": "str",
          "description": "Retrieves product information data for all products in this category.",
          "required": true
        }
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Tools
using RestSharp;

var client = new RestClient("https://api.cohere.com/v1/chat");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"message\": \"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  \"stream\": false,\n  \"model\": \"command-a-03-2025\",\n  \"tools\": [\n    {\n      \"name\": \"query_daily_sales_report\",\n      \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\",\n      \"parameter_definitions\": {\n        \"day\": {\n          \"type\": \"str\",\n          \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n          \"required\": true\n        }\n      }\n    },\n    {\n      \"name\": \"query_product_catalog\",\n      \"description\": \"Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.\",\n      \"parameter_definitions\": {\n        \"category\": {\n          \"type\": \"str\",\n          \"description\": \"Retrieves product information data for all products in this category.\",\n          \"required\": true\n        }\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 = [
  "message": "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?",
  "stream": false,
  "model": "command-a-03-2025",
  "tools": [
    [
      "name": "query_daily_sales_report",
      "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
      "parameter_definitions": ["day": [
          "type": "str",
          "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
          "required": true
        ]]
    ],
    [
      "name": "query_product_catalog",
      "description": "Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.",
      "parameter_definitions": ["category": [
          "type": "str",
          "description": "Retrieves product information data for all products in this category.",
          "required": true
        ]]
    ]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cohere.com/v1/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()
```