test2 / test_groq.py
Martechsol
Restore to latest backup from 13 May - 2026-05-15 17:56
608d6ed
Raw
History Blame Contribute Delete
733 Bytes
import asyncio
import os
import httpx
from dotenv import load_dotenv
load_dotenv()
async def main():
api_key = os.getenv("GROQ_API_KEY")
url = "https://api.groq.com/openai/v1/chat/completions"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
payload = {
"model": "deepseek-r1-distill-llama-70b",
"temperature": 0.0,
"max_tokens": 1200,
"messages": [{"role": "system", "content": "hello"}, {"role": "user", "content": "test"}]
}
async with httpx.AsyncClient() as client:
resp = await client.post(url, headers=headers, json=payload)
print(resp.status_code)
print(resp.text)
asyncio.run(main())