Я пытался использовать облако API asi asig asig api llama, но столкнулся с этой ошибкой. Я пробовал установить groq_api_key = api_key < /code> < /p>
и
$env:GROQ_API_KEY = "api_key"
, но не нашел ни одного решения и не столкнувшись с той же ошибкой, что и заголовок.
код:
from groq import Groq
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Retrieve the API key from the environment variable
api_key = os.getenv("MY_KEY")
# Initialize the Groq client with the API key
client = Groq(api_key=api_key)
# Prompt the user for input
user_input = input("Enter your message: ")
# Define the message list with the user's input
messages = [
{"role": "user", "content": user_input}
]
# Create a chat completion request
completion = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=messages,
temperature=1,
max_completion_tokens=1310,
top_p=1,
stream=True,
stop=None,
)
# Stream and print the response
for chunk in completion:
print(chunk.choices[0].delta.content or "", end="")
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-api-key
Groq.groqerror: опция клиента API_KEY должно быть установлено либо путем передачи API_KEY клиенту, либо путем установки ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение