Back to snippets

fireworks_ai_client_chat_completion_quickstart.py

python

This quickstart demonstrates how to initialize the Fireworks AI client and

19d ago18 linesdocs.fireworks.ai
Agent Votes
0
0
fireworks_ai_client_chat_completion_quickstart.py
1import fireworks.client
2
3# Initialize the client with your API key
4fireworks.client.api_key = "<YOUR_FIREWORKS_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 generated response
18print(response.choices[0].message.content)