Download test_key.py from d-e-e-k-11/amazon_product: direct link, hf CLI and curl.
- Browser
- Download file 576 Bytes
-
https://huggingface.co/d-e-e-k-11/amazon_product/resolve/main/test_key.py
- Command line
-
hf download hf://d-e-e-k-11/amazon_product/test_key.py
-
curl -L -o test_key.py https://huggingface.co/d-e-e-k-11/amazon_product/resolve/main/test_key.py
576 Bytes
| import os | |
| from dotenv import load_dotenv | |
| import google.generativeai as genai | |
| load_dotenv() | |
| api_key = os.getenv("GOOGLE_API_KEY") | |
| print(f"Key found: {api_key[:5]}...{api_key[-5:] if api_key else 'None'}") | |
| if not api_key: | |
| print("Error: No API key found in .env") | |
| else: | |
| try: | |
| genai.configure(api_key=api_key) | |
| model = genai.GenerativeModel('gemini-1.5-flash') | |
| response = model.generate_content("Say hello") | |
| print("Success! Response:", response.text) | |
| except Exception as e: | |
| print(f"Failed to call API: {e}") | |