-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_endpoints.py
More file actions
111 lines (94 loc) · 3.28 KB
/
test_endpoints.py
File metadata and controls
111 lines (94 loc) · 3.28 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
"""
Quick endpoint test for Claude Code OpenAI wrapper.
Run this while the server is running on localhost:8000
"""
import requests
import json
BASE_URL = "http://localhost:8000"
def test_health():
print("Testing /health endpoint...")
try:
response = requests.get(f"{BASE_URL}/health")
print(f" Status: {response.status_code}")
print(f" Response: {response.json()}")
return response.status_code == 200
except Exception as e:
print(f" Error: {e}")
return False
def test_auth_status():
print("\nTesting /v1/auth/status endpoint...")
try:
response = requests.get(f"{BASE_URL}/v1/auth/status")
print(f" Status: {response.status_code}")
print(f" Response: {json.dumps(response.json(), indent=2)}")
return response.status_code == 200
except Exception as e:
print(f" Error: {e}")
return False
def test_models():
print("\nTesting /v1/models endpoint...")
try:
response = requests.get(f"{BASE_URL}/v1/models")
print(f" Status: {response.status_code}")
models = response.json()
print(f" Found {len(models.get('data', []))} models")
for model in models.get('data', [])[:3]: # Show first 3
print(f" - {model.get('id')}")
return response.status_code == 200
except Exception as e:
print(f" Error: {e}")
return False
def test_chat_completion():
print("\nTesting /v1/chat/completions endpoint...")
try:
payload = {
"model": "claude-3-5-haiku-20241022", # Use fastest model
"messages": [
{"role": "user", "content": "Say 'Hello, SDK integration working!' and nothing else."}
],
"max_tokens": 50
}
response = requests.post(
f"{BASE_URL}/v1/chat/completions",
json=payload,
headers={"Content-Type": "application/json"}
)
print(f" Status: {response.status_code}")
if response.status_code == 200:
result = response.json()
content = result.get('choices', [{}])[0].get('message', {}).get('content', '')
print(f" Response: {content}")
print(f" Usage: {result.get('usage', {})}")
return True
else:
print(f" Error: {response.text}")
return False
except Exception as e:
print(f" Error: {e}")
return False
def main():
print("Claude Code OpenAI Wrapper - Endpoint Tests")
print("=" * 50)
tests = [
("Health Check", test_health),
("Auth Status", test_auth_status),
("Models List", test_models),
("Chat Completion", test_chat_completion)
]
passed = 0
total = len(tests)
for name, test_func in tests:
if test_func():
print(f"✓ {name} passed")
passed += 1
else:
print(f"✗ {name} failed")
print("=" * 50)
print(f"Results: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! SDK integration is working correctly.")
else:
print("❌ Some tests failed. Check server logs for details.")
if __name__ == "__main__":
main()