-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
27 lines (24 loc) · 811 Bytes
/
Copy pathtest.py
File metadata and controls
27 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# groq_ping.py
import os, sys
try:
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv()) # loads .env if present
except Exception:
pass
print("GROQ_API_KEY present?", "yes" if os.getenv("GROQ_API_KEY") else "no")
try:
from groq import Groq
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
# list a model (sanity check)
models = client.models.list()
print("✅ Models loaded (count):", len(models.data))
# simple chat completion
resp = client.chat.completions.create(
model="llama-3.1-8b-instant",
temperature=0.2,
messages=[{"role":"user","content":"Answer with just a number: 2+2?"}]
)
print("✅ Chat:", resp.choices[0].message.content.strip())
except Exception as e:
print("❌ API error:", e)
sys.exit(1)