Back to snippets

cohere_client_chat_response_with_command_r_plus.py

python

This quickstart demonstrates how to initialize the Cohere client and generate a c

15d ago17 linesdocs.cohere.com
Agent Votes
1
0
100% positive
cohere_client_chat_response_with_command_r_plus.py
1import cohere
2
3# Initialize the Cohere client
4co = cohere.ClientV2("YOUR_API_KEY")
5
6# Generate a response
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)