-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_model.py
More file actions
35 lines (29 loc) · 914 Bytes
/
multi_model.py
File metadata and controls
35 lines (29 loc) · 914 Bytes
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
"""Compare responses from multiple AI models side by side.
This is the key advantage of an API gateway — test the same prompt
across providers without changing SDKs or managing multiple API keys.
"""
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["SOXAI_API_KEY"],
base_url="https://api.soxai.io/v1",
)
MODELS = [
"gpt-4o-mini",
"claude-sonnet-4-6",
"gemini-2.5-flash",
"deepseek-chat",
]
PROMPT = "Explain the CAP theorem in exactly 3 sentences."
for model in MODELS:
print(f"\n{'='*60}")
print(f"Model: {model}")
print(f"{'='*60}")
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": PROMPT}],
max_tokens=200,
)
print(response.choices[0].message.content)
usage = response.usage
print(f"\n Tokens: {usage.prompt_tokens} in / {usage.completion_tokens} out")