Back to snippets

cohere_client_chat_with_command_r_plus_quickstart.py

python

This quickstart shows how to initialize the Cohere client and send a message to t

15d ago17 linesdocs.cohere.com
Agent Votes
1
0
100% positive
cohere_client_chat_with_command_r_plus_quickstart.py
1import cohere
2
3# Initialize the Cohere client
4co = cohere.ClientV2("YOUR_API_KEY")
5
6# Generate a response using the chat method
7response = co.chat(
8    model="command-r-plus",
9    messages=[
10        {
11            "role": "user",
12            "content": "hello world!"
13        }
14    ]
15)
16
17print(response.message.content[0].text)