from openai import OpenAI
client = OpenAI(
api_key="ваш_ключ",
base_url="https://api.routify.ru/v1"
)
stream = client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Расскажи анекдот"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)