Skip to navigation

OpenAI SDK

Install

pip install openai

Set up the client

import os
from openai import OpenAI
client = OpenAI(
base_url="https://ai.hyperflow.fun/v1",
api_key=os.environ["HYPERFLOW_API_KEY"],
)
response = client.chat.completions.create(
model="openai/gpt-6-luna",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Set OPENAI_BASE_URL and OPENAI_API_KEY in the environment instead, and OpenAI() picks them up with no arguments. Useful for tools built on the SDK that don’t expose a base URL setting.

What works

SDK methodFlow AI
chat.completions.create / .parse / .streamYes. See Streaming, Tool calling, Structured outputs
embeddings.createYes. See Embeddings
images.generate, images.editYes. See Image generation
videos.create, .retrieve, .list, .download_contentYes. See Video generation
models.listYes, the models your key can call
responses, audio, moderations, files, batches, assistantsNot available

Errors and retries

The SDK raises its usual exceptions with Flow AI’s message and code, for example openai.APIStatusError with status 402 for a low balance. It retries 429 and 5xx by itself. See Errors.