-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_groq.py
More file actions
30 lines (25 loc) · 1004 Bytes
/
debug_groq.py
File metadata and controls
30 lines (25 loc) · 1004 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
28
29
30
import asyncio, os
from dotenv import load_dotenv
from groq import AsyncGroq, APIStatusError, RateLimitError
async def main():
load_dotenv() # .env 파일 로드
key = os.getenv("GROQ_API_KEY")
print("GROQ_API_KEY set? ", bool(key))
client = AsyncGroq(api_key=key, timeout=20)
try:
ms = await client.models.list()
print("Models:", [m.id for m in ms.data][:5])
# 원래 모델로 테스트 호출
test_model = "llama-3.3-70b-versatile"
print(f"\n테스트: {test_model}")
response = await client.chat.completions.create(
model=test_model,
messages=[{"role": "user", "content": "테스트"}],
max_tokens=50
)
print("SUCCESS: Groq call worked!")
print("Response:", response.choices[0].message.content[:100])
except (RateLimitError, APIStatusError) as e:
print("❌ Groq API 에러:", e)
if __name__ == "__main__":
asyncio.run(main())