Yash030/claude-code-proxy
2
1"""Test Silicon Flow API key directly."""2 3import os4import httpx5from openai import AsyncOpenAI6 7SILICON_API_KEY = "sk-vkswknrlhztbogulqjizbxpkdipbafudnirbrhzosxjkvmri"8SILICON_BASE_URL = "https://api.siliconflow.cn/v1"9 10 11async def test_models_list():12 """Test listing models."""13 print("=== Testing /v1/models ===")14 async with httpx.AsyncClient() as client:15 try:16 response = await client.get(17 f"{SILICON_BASE_URL}/models",18 headers={"Authorization": f"Bearer {SILICON_API_KEY}"},19 timeout=10.0,20 )21 print(f"Status: {response.status_code}")22 print(f"Response: {response.text[:500]}")23 except Exception as e:24 print(f"Error: {e}")25 26 27async def test_chat():28 """Test a chat completion."""29 print("\n=== Testing /v1/chat/completions ===")30 client = AsyncOpenAI(31 api_key=SILICON_API_KEY,32 base_url=SILICON_BASE_URL,33 timeout=httpx.Timeout(30.0),34 )35 36 models_to_try = [37 "Qwen/Qwen3.6-35B-A3B",38 "Qwen3.6-35B-A3B",39 "Qwen/Qwen2.5-72B-Instruct",40 "Pro/Qwen/Qwen2.5-72B-Instruct",41 ]42 43 for model in models_to_try:44 print(f"\nTrying model: {model}")45 try:46 response = await client.chat.completions.create(47 model=model,48 messages=[{"role": "user", "content": "hi"}],49 max_tokens=10,50 )51 print(f"Success! Response: {response}")52 break53 except Exception as e:54 error_text = str(e)55 # Extract useful part of error56 if hasattr(e, "response") and e.response:57 error_text = e.response.text58 print(f"Error: {error_text[:200]}")59 60 61async def main():62 await test_models_list()63 await test_chat()64 65 66if __name__ == "__main__":67 import asyncio68 69 asyncio.run(main())70 