测试大模型供应商提供的模型是否可以访问
·
import httpx
api_key = "YOUR_API_KEY"
# 测试 SiliconFlow API
url = "https://api.siliconflow.cn/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
}
payload = {
"model": "deepseek-ai/DeepSeek-V3",
"messages": [{"role": "user", "content": "Hello"}],
"temperature": 0.7,
}
try:
response = httpx.post(url, headers=headers, json=payload)
print(f"Status code: {response.status_code}")
print(f"Response: {response.json()}")
except Exception as e:
print(f"Error: {e}")
更多推荐
所有评论(0)