import os import asyncio from groq import AsyncGroq from dotenv import load_dotenv async def test_groq(): load_dotenv(override=True) api_key = os.getenv("GROQ_API_KEY") model = os.getenv("GROQ_MODEL", "llama-3.3-70b-versatile") print(f"Testing Groq API Key: {api_key[:10]}...") client = AsyncGroq(api_key=api_key) try: chat_completion = await client.chat.completions.create( messages=[ { "role": "user", "content": "Respond with 'CONNECTED' if you receive this.", } ], model=model, ) print(f"Result: {chat_completion.choices[0].message.content}") return True except Exception as e: print(f"Error: {e}") return False if __name__ == "__main__": asyncio.run(test_groq())