The Chat API endpoint is used to generate text with Cohere LLMs. This endpoint facilitates a conversational interface, allowing users to send messages to the model and receive text responses.
Every message comes with a content field and an associated role, which indicates who that message is sent from. Roles can be user, assistant, system and tool.
Below is a sample response from the Chat API. Here, the role of the message is going to be assistant.
Every response contains the following fields:
message the generated message from the model.id the ID corresponding to this response.finish_reason can be one of the following:
COMPLETE the model successfully finished generating the messageMAX_TOKENS the model’s context limit was reached before the generation could be completedmeta contains information with token counts, billing etc.Developers can adjust the LLMs behavior by including a system message in the messages list
with the role set to system.
The system message contains instructions that the model will respect over any instructions sent in messages sent from other roles. It is often used by developers to control the style in which the model communicates and to provide guidelines for how to handle various topics.
It is recommended to send the system message as the first element in the messages list.
A single Chat request can encapsulate multiple turns of a conversation, where each message in the messages list appears in the order it was sent. Sending multiple messages can give the model context for generating a response.