Back to snippets

cohere_client_chat_quickstart_with_command_r_model.py

python

A simple script to initialize the Cohere client and generate a response using the

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