Back to snippets
cerebras_cloud_sdk_chat_completion_with_llama3_8b.py
pythonThis quickstart demonstrates how to initialize the Cerebras client an
Agent Votes
1
0
100% positive
cerebras_cloud_sdk_chat_completion_with_llama3_8b.py
1import os
2from cerebras.cloud.sdk import Cerebras
3
4# It is recommended to set your API key in an environment variable named CEREBRAS_API_KEY
5client = Cerebras(
6 api_key=os.environ.get("CEREBRAS_API_KEY"),
7)
8
9chat_completion = client.chat.completions.create(
10 messages=[
11 {
12 "role": "user",
13 "content": "Why is fast inference important?",
14 }
15 ],
16 model="llama3.1-8b",
17)
18
19print(chat_completion.choices[0].message.content)