> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI-Compatible Image Generations

> Generate images with ByteDance Seedream via the standard POST /v1/images/generations endpoint. OpenAI-compatible request shape; minimum image size is 3,686,400 pixels (e.g., 1920×1920).

The standard OpenAI-compatible `POST /v1/images/generations` endpoint. Currently routed to **ByteDance Seedream** (`seedream-4-5-251128`). Wan 2.7 models do **not** use this path — see [Image Generation via Chat](/api-reference/chat/image-generation).

## Routing at a glance

| Model                               | Endpoint                                                                             |
| ----------------------------------- | ------------------------------------------------------------------------------------ |
| `seedream-4-5-251128`               | **`POST /v1/images/generations`** *(this page)*                                      |
| `wan2.7-image` / `wan2.7-image-pro` | [`POST /v1/chat/completions`](/api-reference/chat/image-generation)                  |
| Gemini-compatible models            | [`POST /v1beta/models/{model}:generateContent`](/api-reference/chat/generatecontent) |

## Supported models

| Model                 | Cost per image | Notes                                                 |
| --------------------- | -------------- | ----------------------------------------------------- |
| `seedream-4-5-251128` | \$0.040        | Min image size **3,686,400 pixels** (e.g., 1920×1920) |

## Size constraint ⚠️

Seedream's upstream enforces a minimum of **3,686,400 pixels**. Requests below that are rejected with:

```
400 InvalidParameter: image size must be at least 3686400 pixels
```

| Size        | Pixels    | Accepted?           |
| ----------- | --------- | ------------------- |
| `1024x1024` | 1,048,576 | ❌                   |
| `1536x1536` | 2,359,296 | ❌                   |
| `1920x1920` | 3,686,400 | ✅ (exact threshold) |
| `2048x2048` | 4,194,304 | ✅                   |
| `2304x1600` | 3,686,400 | ✅                   |
| `2560x1920` | 4,915,200 | ✅                   |

Any aspect ratio works as long as `width × height ≥ 3,686,400`.

## Request

<CodeGroup>
  ```bash curl theme={null}
  curl -sS -X POST "https://api.aisa.one/v1/images/generations" \
    -H "Authorization: Bearer $AISA_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "seedream-4-5-251128",
      "prompt": "A cute red panda, ultra-detailed, cinematic lighting",
      "n": 1,
      "size": "2048x2048"
    }'
  ```

  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(base_url="https://api.aisa.one/v1", api_key="sk-aisa-...")

  resp = client.images.generate(
      model="seedream-4-5-251128",
      prompt="A cute red panda, ultra-detailed, cinematic lighting",
      n=1,
      size="2048x2048",
  )

  for item in resp.data:
      print(item.url)
  ```

  ```typescript TypeScript theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.aisa.one/v1",
    apiKey: process.env.AISA_API_KEY,
  });

  const resp = await client.images.generate({
    model: "seedream-4-5-251128",
    prompt: "A cute red panda, ultra-detailed, cinematic lighting",
    n: 1,
    size: "2048x2048",
  });

  for (const item of resp.data) {
    console.log(item.url);
  }
  ```
</CodeGroup>

### Request fields

| Field    | Type    | Required | Notes                                                     |
| -------- | ------- | -------- | --------------------------------------------------------- |
| `model`  | string  | yes      | `seedream-4-5-251128`                                     |
| `prompt` | string  | yes      | Text description of the image to generate                 |
| `n`      | integer | no       | Number of images. Each is billed separately at \$0.040    |
| `size`   | string  | yes      | `WIDTHxHEIGHT`. Must satisfy `width × height ≥ 3,686,400` |

## Response

```json theme={null}
{
  "model": "seedream-4-5-251128",
  "created": 1776495432,
  "data": [
    {
      "url": "https://cdn.aisa.one/images/seedream/...",
      "size": "2048x2048"
    }
  ],
  "usage": {
    "generated_images": 1,
    "output_tokens": 16384,
    "total_tokens": 16384
  }
}
```

**AIsa's response adds a few extensions** over the vanilla OpenAI schema:

* `model` echoed at the root
* `data[].size` — actual dimensions of each returned image
* `usage` — includes `generated_images` (drives billing), plus `output_tokens` / `total_tokens` for token accounting

<Warning>
  URLs in `data[].url` are **short-lived**. Download and persist the image to your own storage before it expires.
</Warning>

## Common 4xx causes

* `400 InvalidParameter — image size must be at least 3686400 pixels` — `size` was too small. Use `1920x1920` or larger.
* `404 openai_error` — you passed a model that isn't routed through this endpoint (e.g., `wan2.7-image`). Use the [chat-based route](/api-reference/chat/image-generation) instead.
* `400 invalid_request` — malformed `size` string (e.g., `1024` instead of `1024x1024`).

See [Error Codes](/api-reference/errors) and [Rate Limits](/api-reference/rate-limits) for more.

## Related

<CardGroup cols={3}>
  <Card title="Image Generation via Chat" icon="message" href="/api-reference/chat/image-generation">
    The `/v1/chat/completions` route for the Wan 2.7 family.
  </Card>

  <Card title="Gemini generateContent" icon="google" href="/api-reference/chat/generatecontent">
    Gemini-compatible generateContent endpoint.
  </Card>

  <Card title="Media Gen skill" icon="image" href="/agent-skills/mediagen">
    Agent skill that wraps image + video generation.
  </Card>
</CardGroup>


## OpenAPI

````yaml openapi/openai-images-generations.json POST /images/generations
openapi: 3.0.3
info:
  title: OpenAI-Compatible Image Generations
  version: 1.0.0
  description: >-
    Standard OpenAI-compatible `POST /v1/images/generations` endpoint. Currently
    supports the **ByteDance Seedream** family. Wan 2.7 image models route
    through [`/v1/chat/completions`](/api-reference/chat/image-generation)
    instead, and Gemini-compatible `generateContent` requests use
    [`/v1beta/models/{model}:generateContent`](/api-reference/chat/generatecontent).
servers:
  - url: https://api.aisa.one/v1
security:
  - BearerAuth: []
paths:
  /images/generations:
    post:
      summary: Generate images (OpenAI-compatible)
      description: >-
        Generate images with the OpenAI-compatible images-generations endpoint.
        Currently routed to **ByteDance Seedream** — the Wan 2.7 family does not
        use this path.


        **Size constraint.** Seedream's upstream requires a minimum of
        **3,686,400 pixels** per image. Requests below that return `400
        InvalidParameter: image size must be at least 3686400 pixels`. A
        1024×1024 image (1,048,576 px) is rejected; 1920×1920 (3,686,400 px) and
        2048×2048 (4,194,304 px) are accepted. Other aspect ratios are fine as
        long as `width × height ≥ 3,686,400`.
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  enum:
                    - seedream-4-5-251128
                  description: >-
                    Image generation model. Currently only `seedream-4-5-251128`
                    is routed through this endpoint. Wan 2.7 models use
                    `/v1/chat/completions`.
                prompt:
                  type: string
                  description: Text description of the image to generate.
                'n':
                  type: integer
                  minimum: 1
                  default: 1
                  description: >-
                    Number of images to generate. Each image is billed
                    separately at the per-image rate.
                size:
                  type: string
                  description: >-
                    Image dimensions as `WIDTHxHEIGHT`. Must satisfy `width ×
                    height ≥ 3,686,400`. Common valid values: `1920x1920`,
                    `2048x2048`, `2304x1600`, `2560x1920`.
                  example: 2048x2048
            examples:
              basic:
                summary: Single 2K image
                value:
                  model: seedream-4-5-251128
                  prompt: A cute red panda, ultra-detailed, cinematic lighting
                  'n': 1
                  size: 2048x2048
              minimum_size:
                summary: Exactly at minimum allowed size (1920×1920)
                value:
                  model: seedream-4-5-251128
                  prompt: A futuristic cyberpunk city, neon lights, rainy night, 8k
                  'n': 1
                  size: 1920x1920
              batch:
                summary: Four candidates for selection
                value:
                  model: seedream-4-5-251128
                  prompt: Oil painting of a rolling hillside at sunset
                  'n': 4
                  size: 2048x2048
      responses:
        '200':
          description: Images generated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  model:
                    type: string
                    example: seedream-4-5-251128
                  created:
                    type: integer
                    example: 1776495432
                  data:
                    type: array
                    description: One entry per generated image.
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          format: uri
                          description: >-
                            Short-lived URL to the generated image. Download and
                            persist it; the URL expires.
                        size:
                          type: string
                          description: Actual dimensions of the returned image.
                  usage:
                    type: object
                    properties:
                      generated_images:
                        type: integer
                      output_tokens:
                        type: integer
                      total_tokens:
                        type: integer
              example:
                model: seedream-4-5-251128
                created: 1776495432
                data:
                  - url: https://cdn.aisa.one/images/seedream/20260418-abc.png
                    size: 2048x2048
                usage:
                  generated_images: 1
                  output_tokens: 16384
                  total_tokens: 16384
        '400':
          description: >-
            Invalid request. Most common: `size` smaller than 3,686,400 pixels →
            `"image size must be at least 3686400 pixels"`.
        '401':
          description: Missing or invalid AIsa API key.
        '404':
          description: >-
            The model isn't routed through this endpoint. Wan 2.7 models return
            `openai_error` here — use `/v1/chat/completions` for those.
        '429':
          description: Rate limit hit.
        '500':
          description: Internal error.
        '502':
          description: Upstream provider unreachable.
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: AISA API Key

````