Physical-AI-Backend / test_api.py
Fizu123's picture
Upload 16 files
1c29d49 verified
import os
import requests
# Load the API key from environment
api_key = os.getenv("TRANSLATION_API_KEY", "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")
model = os.getenv("TRANSLATION_MODEL", "allenai/olmo-3.1-32b-think:free")
print(f"Testing API key: {api_key[:10]}...") # Only show first 10 chars for security
print(f"Testing model: {model}")
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}
payload = {
"model": model,
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}
try:
response = requests.post(
"https://openrouter.ai/api/v1/chat/completions",
json=payload,
headers=headers,
timeout=30
)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
if response.status_code == 200:
print("\n✅ API key is working correctly!")
else:
print(f"\n❌ API returned error: {response.status_code}")
print("This might indicate:")
print("1. API key has reached daily limit")
print("2. Model is not available")
print("3. API key is invalid")
except Exception as e:
print(f"\n❌ Error making API request: {str(e)}")