---
title: "Chat API (v1)"
method: POST
path: "/v1/chat"
---

# Chat API (v1)

`POST /v1/chat`

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

## Headers

- `X-Client-Name` string
- `Accepts` 'text/event-stream'

## Request body

- object
  - `message` string, required — Text input for the model to respond to. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments
  - `model` string — 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
  - `stream` boolean — 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
  - `preamble` string — 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` Message[] — 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
    - union
      - object — 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.
        - `role` 'CHATBOT' | 'SYSTEM' | 'USER' | 'TOOL', required — One of `CHATBOT`, `SYSTEM`, `TOOL` or `USER` to identify who the message is coming from.
        - `message` string, required — Contents of the chat message.
        - `tool_calls` ToolCall[]
          - `name` string, required — Name of the tool to call.
          - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
      - object — Represents tool result in the chat history.
        - `role` 'CHATBOT' | 'SYSTEM' | 'USER' | 'TOOL', required — One of `CHATBOT`, `SYSTEM`, `TOOL` or `USER` to identify who the message is coming from.
        - `tool_results` ToolResult[]
          - `call` ToolCall, required — Contains the tool calls generated by the model. Use it to invoke your tools.
            - `name` string, required — Name of the tool to call.
            - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
          - `outputs` object[], required
  - `conversation_id` string — 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` 'OFF' | 'AUTO' | 'AUTO_PRESERVE_ORDER' — 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
  - `connectors` ChatConnector[] — 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
    - `id` string, required — The identifier of the connector.
    - `user_access_token` string — 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 — Defaults to `false`. When `true`, the request will continue if this connector returned an error.
    - `options` object — 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.
  - `search_queries_only` boolean — 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
  - `documents` ChatDocument[] — 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
    - `id` string — Unique identifier for this document.
  - `citation_quality` 'ENABLED' | 'DISABLED' | 'FAST' | 'ACCURATE' | 'OFF' — 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
  - `temperature` number, float — 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 — 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 — 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 — 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` number — 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 — 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` string[] — 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` number — 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` number — 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 — 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` Tool[] — 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
    - `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` object — 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> } } ```
  - `tool_results` ToolResult[] — 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
    - `call` ToolCall, required — Contains the tool calls generated by the model. Use it to invoke your tools.
      - `name` string, required — Name of the tool to call.
      - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
    - `outputs` object[], required
  - `force_single_step` boolean — Forces the chat to be single step. Defaults to `false`.
  - `response_format` union — 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).
    - object
      - `type` 'text' | 'json_object', required — Defaults to `"text"`. When set to `"json_object"`, the model's output will be a valid JSON Object.
    - object
      - `type` 'text' | 'json_object', required — Defaults to `"text"`. When set to `"json_object"`, the model's output will be a valid JSON Object.
      - `schema` object — 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"`.
  - `safety_mode` 'CONTEXTUAL' | 'STRICT' | 'NONE' — 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

## Response `200`

OK

- union
  - NonStreamedChatResponse
    - `text` string, required — Contents of the reply generated by the model.
    - `generation_id` string, uuid — Unique identifier for the generated reply. Useful for submitting feedback.
    - `response_id` string, uuid — Unique identifier for the response.
    - `citations` ChatCitation[] — Inline citations for the generated reply.
      - `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` string[], required — Identifiers of documents cited by this section of the generated reply.
      - `type` 'TEXT_CONTENT' | 'PLAN' — The type of citation which indicates what part of the response the citation is for.
    - `documents` ChatDocument[] — Documents seen by the model when generating the reply.
      - `id` string — Unique identifier for this document.
    - `is_search_required` boolean — Denotes that a search for documents is required during the RAG flow.
    - `search_queries` ChatSearchQuery[] — Generated search queries, meant to be used as part of the RAG flow.
      - `text` string, required — The text of the search query.
      - `generation_id` string, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
    - `search_results` ChatSearchResult[] — Documents retrieved from each of the conducted searches.
      - `search_query` 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, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
      - `connector` ChatSearchResultConnector, required — The connector used for fetching documents.
        - `id` string, required — The identifier of the connector.
      - `document_ids` string[], required — Identifiers of documents found by this search query.
      - `error_message` string — An error message if the search failed.
      - `continue_on_failure` boolean — Whether a chat request should continue or not if the request to this connector fails.
    - `finish_reason` 'COMPLETE' | 'STOP_SEQUENCE' | 'ERROR' | 'ERROR_TOXIC' | 'ERROR_LIMIT' | 'USER_CANCEL' | 'MAX_TOKENS' | 'TIMEOUT'
    - `tool_calls` ToolCall[]
      - `name` string, required — Name of the tool to call.
      - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
    - `chat_history` Message[] — 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`.
      - union
        - object — 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.
          - `role` 'CHATBOT' | 'SYSTEM' | 'USER' | 'TOOL', required — One of `CHATBOT`, `SYSTEM`, `TOOL` or `USER` to identify who the message is coming from.
          - `message` string, required — Contents of the chat message.
          - `tool_calls` ToolCall[]
            - `name` string, required — Name of the tool to call.
            - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
        - object — Represents tool result in the chat history.
          - `role` 'CHATBOT' | 'SYSTEM' | 'USER' | 'TOOL', required — One of `CHATBOT`, `SYSTEM`, `TOOL` or `USER` to identify who the message is coming from.
          - `tool_results` ToolResult[]
            - `call` ToolCall, required — Contains the tool calls generated by the model. Use it to invoke your tools.
              - …
            - `outputs` object[], required
              - …
    - `meta` ApiMeta
      - `api_version` object
        - `version` string, required
        - `is_deprecated` boolean
        - `is_experimental` boolean
      - `billed_units` object
        - `images` number — The number of billed images.
        - `input_tokens` number — The number of billed input tokens.
        - `image_tokens` number — The number of billed image tokens.
        - `output_tokens` number — The number of billed output tokens.
        - `search_units` number — The number of billed search units.
        - `classifications` number — The number of billed classifications units.
      - `tokens` object
        - `input_tokens` number — The number of tokens used as input to the model.
        - `output_tokens` number — The number of tokens produced by the model.
      - `cached_tokens` number — The number of prompt tokens that hit the inference cache.
      - `warnings` string[]
  - union — StreamedChatResponse is returned in streaming mode (specified with `stream=True` in the request).
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `generation_id` string, uuid, required — Unique identifier for the generated reply. Useful for submitting feedback.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `search_queries` ChatSearchQuery[], required — Generated search queries, meant to be used as part of the RAG flow.
        - `text` string, required — The text of the search query.
        - `generation_id` string, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `search_results` ChatSearchResult[] — Conducted searches and the ids of documents retrieved from each of them.
        - `search_query` 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, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
        - `connector` ChatSearchResultConnector, required — The connector used for fetching documents.
          - `id` string, required — The identifier of the connector.
        - `document_ids` string[], required — Identifiers of documents found by this search query.
        - `error_message` string — An error message if the search failed.
        - `continue_on_failure` boolean — Whether a chat request should continue or not if the request to this connector fails.
      - `documents` ChatDocument[] — Documents fetched from searches or provided by the user.
        - `id` string — Unique identifier for this document.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `text` string, required — The next batch of text generated by the model.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `citations` ChatCitation[], required — Citations for the generated reply.
        - `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` string[], required — Identifiers of documents cited by this section of the generated reply.
        - `type` 'TEXT_CONTENT' | 'PLAN' — The type of citation which indicates what part of the response the citation is for.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `text` string — The text generated related to the tool calls generated
      - `tool_calls` ToolCall[], required
        - `name` string, required — Name of the tool to call.
        - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `finish_reason` 'COMPLETE' | 'ERROR_LIMIT' | 'MAX_TOKENS' | 'ERROR' | 'ERROR_TOXIC', required — - `COMPLETE` - the model sent back a finished reply - `ERROR_LIMIT` - the reply was cut off because the model reached the maximum number of tokens for its context length - `MAX_TOKENS` - the reply was cut off because the model reached the maximum number of tokens specified by the max_tokens parameter - `ERROR` - something went wrong when generating the reply - `ERROR_TOXIC` - the model generated a reply that was deemed toxic
      - `response` NonStreamedChatResponse, required
        - `text` string, required — Contents of the reply generated by the model.
        - `generation_id` string, uuid — Unique identifier for the generated reply. Useful for submitting feedback.
        - `response_id` string, uuid — Unique identifier for the response.
        - `citations` ChatCitation[] — Inline citations for the generated reply.
          - `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` string[], required — Identifiers of documents cited by this section of the generated reply.
          - `type` 'TEXT_CONTENT' | 'PLAN' — The type of citation which indicates what part of the response the citation is for.
        - `documents` ChatDocument[] — Documents seen by the model when generating the reply.
          - `id` string — Unique identifier for this document.
        - `is_search_required` boolean — Denotes that a search for documents is required during the RAG flow.
        - `search_queries` ChatSearchQuery[] — Generated search queries, meant to be used as part of the RAG flow.
          - `text` string, required — The text of the search query.
          - `generation_id` string, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
        - `search_results` ChatSearchResult[] — Documents retrieved from each of the conducted searches.
          - `search_query` 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, uuid, required — Unique identifier for the generated search query. Useful for submitting feedback.
          - `connector` ChatSearchResultConnector, required — The connector used for fetching documents.
            - `id` string, required — The identifier of the connector.
          - `document_ids` string[], required — Identifiers of documents found by this search query.
          - `error_message` string — An error message if the search failed.
          - `continue_on_failure` boolean — Whether a chat request should continue or not if the request to this connector fails.
        - `finish_reason` 'COMPLETE' | 'STOP_SEQUENCE' | 'ERROR' | 'ERROR_TOXIC' | 'ERROR_LIMIT' | 'USER_CANCEL' | 'MAX_TOKENS' | 'TIMEOUT'
        - `tool_calls` ToolCall[]
          - `name` string, required — Name of the tool to call.
          - `parameters` object, required — The name and value of the parameters to use when invoking a tool.
        - `chat_history` Message[] — 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`.
          - union
            - object — 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.
              - …
            - object — Represents tool result in the chat history.
              - …
        - `meta` ApiMeta
          - `api_version` object
            - `version` string, required
            - `is_deprecated` boolean
            - `is_experimental` boolean
          - `billed_units` object
            - `images` number — The number of billed images.
            - `input_tokens` number — The number of billed input tokens.
            - `image_tokens` number — The number of billed image tokens.
            - `output_tokens` number — The number of billed output tokens.
            - `search_units` number — The number of billed search units.
            - `classifications` number — The number of billed classifications units.
          - `tokens` object
            - `input_tokens` number — The number of tokens used as input to the model.
            - `output_tokens` number — The number of tokens produced by the model.
          - `cached_tokens` number — The number of prompt tokens that hit the inference cache.
          - `warnings` string[]
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `tool_call_delta` ToolCallDelta, required — Contains the chunk of the tool call generation in the stream.
        - `name` string — Name of the tool call
        - `index` number — Index of the tool call generated
        - `parameters` string — Chunk of the tool parameters
        - `text` string — Chunk of the tool plan text
      - `text` string
    - object
      - `event_type` 'stream-start' | 'search-queries-generation' | 'search-results' | 'text-generation' | 'citation-generation' | 'stream-end' | 'debug', required
      - `prompt` string

## Other responses

- `400` — 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
- `401` — 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
- `403` — 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
- `404` — 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
- `422` — 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
- `429` — Too many requests
- `498` — This error is returned when a request or response contains a deny-listed token.
- `499` — This error is returned when a request is cancelled by the user.
- `500` — This error is returned when an uncategorised internal server error occurs.
- `501` — This error is returned when the requested feature is not implemented.
- `503` — 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
- `504` — 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

---

[API](https://skmtc.net/cohere-ai/apis/api-reference.md) · [All operations](https://skmtc.net/cohere-ai/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cohere-ai/api-reference/versions/dbed69eda210/schema)
