Spaces:
Runtime error
Runtime error
File size: 955 Bytes
807b1cf 2fba167 adca139 2fba167 28079b9 2fba167 adca139 807b1cf 2fba167 807b1cf adca139 807b1cf 2fba167 adca139 2fba167 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import os
import requests
def test_together_api():
TOGETHER_API_KEY = os.environ.get("TOGETHER_API_KEY")
print("🔍 API Key starts with:", TOGETHER_API_KEY[:8] if TOGETHER_API_KEY else "None")
if not TOGETHER_API_KEY:
raise RuntimeError("❌ TOGETHER_API_KEY not found. Set it in Hugging Face > Settings > Secrets.")
url = "https://api.together.xyz/v1/chat/completions"
headers = {
"Authorization": f"Bearer {TOGETHER_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
"messages": [{"role": "user", "content": "Write a SQL query to select all rows from table `df`"}],
"temperature": 0.2,
"max_tokens": 200
}
response = requests.post(url, headers=headers, json=payload)
print("✅ API call status:", response.status_code)
print("📦 Response JSON:", response.json())
test_together_api()
|