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.
Servers
- https://api.cohere.com
Request headers
Name | Type | Required | Description |
---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
Accepts |
String | No |
Pass text/event-stream to receive the streamed response as server-sent events. The default is Possible values:
|
X-Client-Name |
String | No |
The name of the project that is making the request. |
Request body fields
Name | Type | Required | Description |
---|---|---|---|
safety_mode |
String | No |
Used to select the safety instruction inserted into the prompt. Defaults to Safety modes are not yet configurable in combination with Note: This parameter is only compatible newer Cohere models, starting with Command R 08-2024 and Command R+ 08-2024. Note: Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments Possible values:
|
temperature |
Number | No |
Defaults to 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 Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
tools[] |
Array | No |
A list of available tools (functions) that the model may suggest invoking before producing a text response. When Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
tools[].name |
String | Yes |
The name of the tool to be called. Valid names contain only the characters |
tools[].description |
String | Yes |
The description of what the tool does, the model uses the description to choose when and how to call the function. |
tools[].parameter_definitions |
Object | No |
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
|
max_input_tokens |
Integer | No |
The maximum number of input tokens to send to the model. If not specified, Input will be truncated according to the Compatible Deployments: Cohere Platform |
force_single_step |
Boolean | No |
Forces the chat to be single step. Defaults to |
preamble |
String | No |
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 The Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
response_format |
Object | No |
Configuration for forcing the model output to adhere to the specified format. Supported on Command R 03-2024, Command R+ 04-2024 and newer models. The model can be forced into outputting JSON objects (with up to 5 levels of nesting) by setting A JSON Schema can optionally be provided, to ensure a specific structure. Note: When using |
conversation_id |
String | No |
An alternative to Providing a Compatible Deployments: Cohere Platform |
documents[] |
Array | No |
A list of relevant documents that the model can cite to generate a more accurate reply. Each document is a string-string dictionary. Example:
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 An See 'Document Mode' in the guide for more information. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
documents[].id |
String | No |
Unique identifier for this document. |
seed |
Integer | No |
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 |
message |
String | Yes |
Text input for the model to respond to. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
tool_results[] |
Array | No |
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 Note:
Note: Chat calls with Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
tool_results[].outputs[] |
Array | Yes | |
tool_results[].call |
Object | Yes |
Contains the tool calls generated by the model. Use it to invoke your tools. |
tool_results[].call.name |
String | Yes |
Name of the tool to call. |
tool_results[].call.parameters |
Object | Yes |
The name and value of the parameters to use when invoking a tool. |
stream |
Boolean | No |
Defaults to When 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 |
k |
Integer | No |
Ensures only the top Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments Default value: 0 |
chat_history[] |
Array | No |
A list of previous messages between the user and the model, giving the model conversational context for responding to the user's Each item represents a single message in the chat history, excluding the current user turn. It has two properties: The chat_history parameter should not be used for Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
citation_quality |
String | No |
Defaults to Dictates the approach taken to generating citations as part of the RAG flow by allowing the user to specify whether they want Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments Possible values:
|
prompt_truncation |
String | No |
Defaults to Dictates how the prompt will be constructed. With With With Compatible Deployments:
Possible values:
|
p |
Number | No |
Ensures that only the most likely tokens, with total probability mass of Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments Default value: 0.75 |
search_queries_only |
Boolean | No |
Defaults to When Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
model |
String | No |
The name of a compatible Cohere model or the ID of a fine-tuned model. Compatible Deployments: Cohere Platform, Private Deployments |
frequency_penalty |
Number | No |
Defaults to 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 | No |
Defaults to Used to reduce repetitiveness of generated tokens. Similar to Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker/Bedrock, Private Deployments |
max_tokens |
Integer | No |
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 |
stop_sequences[] |
Array | No |
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 |
connectors[] |
Array | No |
Accepts When specified, the model's reply will be enriched with information found by querying each of the connectors (RAG). Compatible Deployments: Cohere Platform |
connectors[].id |
String | Yes |
The identifier of the connector. |
connectors[].options |
Object | No |
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 |
connectors[].user_access_token |
String | No |
When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one. |
connectors[].continue_on_failure |
Boolean | No |
Defaults to When |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.