Spaces:
Running
Running
| 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()) | |