Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| # Test gemini-2.5-flash with the user's API key | |
| API_KEY = "AIzaSyDI723T9EkKYy03FczrycRhEAdW7Ps7d38" | |
| print(f"Testing gemini-2.5-flash...") | |
| url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key={API_KEY}" | |
| payload = { | |
| "contents": [{ | |
| "parts": [{"text": "Say hello in one word"}] | |
| }] | |
| } | |
| try: | |
| response = requests.post(url, json=payload, timeout=30) | |
| print(f"Status code: {response.status_code}") | |
| if response.status_code != 200: | |
| print(f"Error response: {response.text}") | |
| else: | |
| data = response.json() | |
| print(f"Success!") | |
| # Extract text | |
| if "candidates" in data and len(data["candidates"]) > 0: | |
| candidate = data["candidates"][0] | |
| if "content" in candidate and "parts" in candidate["content"]: | |
| parts = candidate["content"]["parts"] | |
| if len(parts) > 0 and "text" in parts[0]: | |
| print(f"Extracted text: '{parts[0]['text']}'") | |
| except Exception as e: | |
| print(f"Exception: {e}") | |
| import traceback | |
| traceback.print_exc() | |