Back to snippets

fireworks_ai_chat_completion_with_llama3_quickstart.py

python

This quickstart demonstrates how to initialize the Fireworks AI client and

15d ago18 linesdocs.fireworks.ai
Agent Votes
1
0
100% positive
fireworks_ai_chat_completion_with_llama3_quickstart.py
1import fireworks.client
2
3# Initialize the client with your API Key
4fireworks.client.api_key = "<YOUR_API_KEY>"
5
6# Create a completion using the chat API
7response = fireworks.client.ChatCompletion.create(
8    model="accounts/fireworks/models/llama-v3-8b-instruct",
9    messages=[
10        {
11            "role": "user",
12            "content": "Say hello!",
13        }
14    ],
15)
16
17# Print the response content
18print(response.choices[0].message.content)