File size: 1,923 Bytes
0ba585f
db83b53
0ba585f
 
 
 
 
 
 
db83b53
0ba585f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db83b53
0ba585f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db83b53
0ba585f
 
 
db83b53
0ba585f
 
 
 
db83b53
0ba585f
 
db83b53
 
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""Test Silicon Flow API key directly."""

import os
import httpx
from openai import AsyncOpenAI

SILICON_API_KEY = "sk-vkswknrlhztbogulqjizbxpkdipbafudnirbrhzosxjkvmri"
SILICON_BASE_URL = "https://api.siliconflow.cn/v1"


async def test_models_list():
    """Test listing models."""
    print("=== Testing /v1/models ===")
    async with httpx.AsyncClient() as client:
        try:
            response = await client.get(
                f"{SILICON_BASE_URL}/models",
                headers={"Authorization": f"Bearer {SILICON_API_KEY}"},
                timeout=10.0,
            )
            print(f"Status: {response.status_code}")
            print(f"Response: {response.text[:500]}")
        except Exception as e:
            print(f"Error: {e}")


async def test_chat():
    """Test a chat completion."""
    print("\n=== Testing /v1/chat/completions ===")
    client = AsyncOpenAI(
        api_key=SILICON_API_KEY,
        base_url=SILICON_BASE_URL,
        timeout=httpx.Timeout(30.0),
    )

    models_to_try = [
        "Qwen/Qwen3.6-35B-A3B",
        "Qwen3.6-35B-A3B",
        "Qwen/Qwen2.5-72B-Instruct",
        "Pro/Qwen/Qwen2.5-72B-Instruct",
    ]

    for model in models_to_try:
        print(f"\nTrying model: {model}")
        try:
            response = await client.chat.completions.create(
                model=model,
                messages=[{"role": "user", "content": "hi"}],
                max_tokens=10,
            )
            print(f"Success! Response: {response}")
            break
        except Exception as e:
            error_text = str(e)
            # Extract useful part of error
            if hasattr(e, "response") and e.response:
                error_text = e.response.text
            print(f"Error: {error_text[:200]}")


async def main():
    await test_models_list()
    await test_chat()


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())