import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.aireserve.com/v1", # note the /v1 suffix
api_key=os.environ["AIRESERVE_API_KEY"],
)
# Works with GPT models — and with Claude/Gemini/... model IDs too.
res = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "hello"}],
)
print(res.choices[0].message.content)
# Streaming works unchanged too:
for chunk in client.chat.completions.create(
model="claude-sonnet-4-6", # cross-provider: Claude via the OpenAI SDK
messages=[{"role": "user", "content": "hello"}],
stream=True,
):
# The final chunk carries usage and an empty `choices` list.
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")