> Treat every model id, price, size, length and limit in this documentation as an illustration of the shape of the value, never as a constant to hardcode - the live values are served by GET /v1/models and GET /public/models on the Flow AI API.

# OpenAI SDK

> The official Python and TypeScript clients, pointed at Flow AI.

## Install

**`Python`**

```bash title="Python"
pip install openai
```

**`TypeScript`**

```bash title="TypeScript"
npm install openai
```

## Set up the client

**`Python`**

```python title="Python"
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)
```

**`TypeScript`**

```typescript title="TypeScript"
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://ai.hyperflow.fun/v1',
  apiKey: process.env.HYPERFLOW_API_KEY,
})

const response = await client.chat.completions.create({
  model: 'openai/gpt-6-luna',
  messages: [{ role: 'user', content: 'Hello!' }],
})
console.log(response.choices[0].message.content)
```

> **Tip**
>
> 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 method                                                            | Flow AI                                                                                                                               |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `chat.completions.create` / `.parse` / `.stream`                      | Yes. See [Streaming](/features/streaming), [Tool calling](/features/tool-calling), [Structured outputs](/features/structured-outputs) |
| `embeddings.create`                                                   | Yes. See [Embeddings](/features/embeddings)                                                                                           |
| `images.generate`, `images.edit`                                      | Yes. See [Image generation](/multimodal/image-generation)                                                                             |
| `videos.create`, `.retrieve`, `.list`, `.download_content`            | Yes. See [Video generation](/multimodal/video-generation)                                                                             |
| `models.list`                                                         | Yes, the models your key can call                                                                                                     |
| `responses`, `audio`, `moderations`, `files`, `batches`, `assistants` | Not 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](/api/errors).