Spaces:
Sleeping
Sleeping
| import requests, json | |
| # Test OpenRouter directly to confirm keys work | |
| keys = [ | |
| "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", | |
| "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", | |
| ] | |
| for i, key in enumerate(keys): | |
| try: | |
| r = requests.post( | |
| "https://openrouter.ai/api/v1/chat/completions", | |
| headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"}, | |
| json={ | |
| "model": "google/gemini-2.0-flash-001", | |
| "messages": [{"role": "user", "content": "Say hello in 3 words"}], | |
| "max_tokens": 20, | |
| }, | |
| timeout=8, | |
| ) | |
| print(f"Key {i+1}: status={r.status_code}") | |
| if r.status_code == 200: | |
| print(f" Response: {r.json()['choices'][0]['message']['content']}") | |
| break | |
| else: | |
| print(f" Error: {r.text[:200]}") | |
| except Exception as e: | |
| print(f"Key {i+1}: FAILED - {e}") | |