Spaces:
Runtime error
Runtime error
Download test_api.py from Akash8150/Pare-AI-Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 533 Bytes
-
https://huggingface.co/spaces/Akash8150/Pare-AI-Chatbot/resolve/main/test_api.py
- Command line
-
hf download hf://spaces/Akash8150/Pare-AI-Chatbot/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/Akash8150/Pare-AI-Chatbot/resolve/main/test_api.py
533 Bytes
| import google.generativeai as genai | |
| from dotenv import load_dotenv | |
| import os | |
| load_dotenv() | |
| api_key = os.getenv('GEMINI_API_KEY') | |
| print(f"Testing API Key: {api_key[:10]}...{api_key[-4:]}") | |
| print(f"Key length: {len(api_key)}") | |
| try: | |
| genai.configure(api_key=api_key) | |
| model = genai.GenerativeModel("models/gemini-flash-lite-latest") | |
| response = model.generate_content("Say 'Hello'") | |
| print("✅ SUCCESS! API Key is valid!") | |
| print(f"Response: {response.text}") | |
| except Exception as e: | |
| print(f"❌ ERROR: {str(e)}") | |