Docs
Python SDK
Use the official openai Python package against the EasyAI gateway — chat, streaming, and image generation.
Install
The gateway works with the standard openai package from PyPI.
bash
pip install openaiChat completion
Set base_url to the gateway and use your EasyAI key. Everything else — messages, tools, JSON mode — works as with OpenAI.
chat.py
from openai import OpenAI
client = OpenAI(
base_url="https://easyairoute.com/v1",
api_key="sk-...",
)
resp = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Explain quic in one paragraph."}],
)
print(resp.choices[0].message.content)Streaming
Pass stream=True and iterate over the chunks as they arrive.
stream.py
stream = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Count to five slowly."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)Image generation
Image models use the images endpoint and are billed per generated item.
image.py
resp = client.images.generate(
model="gpt-image-2",
prompt="A paper crane on a dark desk, studio light",
size="1024x1024",
)
print(resp.data[0].url)