在 Groq 上使用 Llama 3
Groq + Llama 3 + Portkey
使用超快速的 Groq API 与 OpenAI 兼容的 Portkey!
!pip install -qU portkey-ai openai使用 OpenAI 客户端
from openai import OpenAI
from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders
from google.colab import userdata
client = OpenAI(
api_key= userdata.get('GROQ_API_KEY'), ## replace it your Groq API key
base_url=PORTKEY_GATEWAY_URL,
default_headers=createHeaders(
provider="groq",
api_key= userdata.get('PORTKEY_API_KEY'), ## replace it your Portkey API key
)
)
chat_complete = client.chat.completions.create(
model="llama3-70b-8192",
messages=[{"role": "user",
"content": "What's the purpose of Generative AI?"}],
)
print(chat_complete.choices[0].message.content)使用 Portkey 客户端
使用 Portkey 进行可观察性
Last updated