packages/tasks-gen/snippets-fixtures/explicit-direct-request/python/huggingface_hub/0.together.py (16 lines of code) (raw):
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="together",
api_key=os.environ["TOGETHER_API_KEY"],
)
completion = client.chat.completions.create(
model="meta-llama/Llama-3.1-8B-Instruct",
messages=[
{
"role": "user",
"content": "What is the capital of France?"
}
],
)
print(completion.choices[0].message)