> ## 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.

> ## Agent Instructions
> - Base URLs: models `https://api.aisa.one/v1` (Gemini GenerateContent: `https://api.aisa.one/v1beta`); data APIs `https://api.aisa.one/apis/v1`. The `servers` of each operation in https://aisa.one/openapi.yaml is authoritative.
> - Auth: `Authorization: Bearer $AISA_API_KEY`. Never print, log, or commit the key.
> - MCP (preferred for agents): `https://mcp.aisa.one/mcp`, signed in with OAuth, so there is no key to paste.
> - Agent Skill: `npx skills add AIsa-team/agent-skills --skill aisa`. Fallback with the AIsa CLI: `aisa skills install aisa`.
> - Spending: docs, https://aisa.one/models, https://aisa.one/api, `/v1/models`, and MCP `search`, `list_categories`, `get_details`, `batch_quote`, and the `account` operation are free. Quote the exact calls before running them (MCP `batch_quote`, CLI `aisa quote --json`). If the quote reports `auto_execute_eligible: true`, run it unless the user set a tighter limit or asked only for a quote. Otherwise, tell the user in one message the planned calls, the quoted price, and a total USD budget for the task, then wait for approval. Direct HTTP calls follow the stricter rule at https://aisa.one/docs/get-started/cli.md#direct-http-fallback. Do not make paid calls to test availability. Full rule: https://aisa.one/llms.txt

# Generate images

> 通过标准的 POST /v1/images/generations endpoint，使用 Seedream、Wan、gpt-image-2 和 GPT Image 2.5 生成图像。请求结构为 OpenAI 兼容；Seedream 路由要求图像最小尺寸为 3,686,400 像素（例如 1920×1920）。

标准的 OpenAI 兼容 `POST /v1/images/generations` endpoint。截至 2026 年 9 月 30 日，它服务 `seedream-5-0-260128`、`wan2.7-image`、`wan2.7-image-pro`、`gpt-image-2`、`gpt-image-2.5-flare` 和 `gpt-image-2.5-sunburst`。`POST /v1/chat/completions` 上没有可用的图像模型——图像生成统一走本 endpoint（标注处另支持 `POST /v1/images/edits`）。

## 路由速览

| 模型 | Endpoint |
| - | - |
| `seedream-5-0-260128` | **`POST /v1/images/generations`** *(本页)* |
| `wan2.7-image` / `wan2.7-image-pro` | **`POST /v1/images/generations`** *(本页)*、`POST /v1/images/edits` |
| `gpt-image-2` | **`POST /v1/images/generations`** *(本页)*、`POST /v1/images/edits` |
| `gpt-image-2.5-flare` / `gpt-image-2.5-sunburst` | **`POST /v1/images/generations`** *(本页)*、`POST /v1/images/edits` |
| Gemini 兼容模型 | [`POST /v1beta/models/{model}:generateContent`](https://aisa.one/docs/zh/api-reference/chat/post_models-model-generatecontent) |

## 支持的模型

| 模型 | 计费方式 | 说明 |
| - | - | - |
| `seedream-5-0-260128` | 按次请求 | 图像最小尺寸 **3,686,400 像素**（例如 1920×1920） |
| `wan2.7-image` | 按次请求 | 同时支持 `POST /v1/images/edits` |
| `wan2.7-image-pro` | 按次请求 | 质量更高的 Wan 路由 |
| `gpt-image-2` | 按 1M Token：输入、输出、缓存写入 | 参见 [AI 模型价格](https://aisa.one/docs/zh/guides/pricing.md#模型) |
| `gpt-image-2.5-flare` | 按 1M Token：输入、输出、缓存读取 | GPT Image 2.5 路由 |
| `gpt-image-2.5-sunburst` | 按 1M Token：输入、输出、缓存读取 | GPT Image 2.5 路由 |

当前价格见 [aisa.one/models](https://aisa.one/models)。

## 尺寸限制 ⚠️（Seedream 路由）

Seedream 上游强制要求最少 **3,686,400 像素**。低于该值的请求会被拒绝：

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

| 尺寸 | 像素数 | 是否接受？ |
| - | - | - |
| `1024x1024` | 1,048,576 | ❌ |
| `1536x1536` | 2,359,296 | ❌ |
| `1920x1920` | 3,686,400 | ✅（正好达到阈值） |
| `2048x2048` | 4,194,304 | ✅ |
| `2304x1600` | 3,686,400 | ✅ |
| `2560x1920` | 4,915,200 | ✅ |

只要 `宽 × 高 ≥ 3,686,400`，任意宽高比都可以。

## 请求

```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-5-0-260128",
    "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-5-0-260128",
    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-5-0-260128",
  prompt: "A cute red panda, ultra-detailed, cinematic lighting",
  n: 1,
  size: "2048x2048",
});

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

### 请求字段

| 字段 | 类型 | 必填 | 说明 |
| - | - | - | - |
| `model` | string | 是 | `seedream-5-0-260128`、`wan2.7-image`、`wan2.7-image-pro`、`gpt-image-2`、`gpt-image-2.5-flare`、`gpt-image-2.5-sunburst` 之一 |
| `prompt` | string | 是 | 要生成图像的文字描述 |
| `n` | integer | 否 | 生成图像数量。按次计费的模型无论 `n` 是多少都只收一次请求费用；按 token 计费的模型按其上报的 token 用量计费 |
| `size` | string | 否 | `宽x高`。Seedream 路由必须满足 `宽 × 高 ≥ 3,686,400`；`wan2.7-image` 和 `gpt-image-2` 可接受更小尺寸（已验证 `1024x1024` 可用） |

## 响应

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

**AIsa 的响应在原生 OpenAI schema 之上增加了几处扩展：**

* 根层级回显 `model`
* `data[].size`——每张返回图像的实际尺寸
* `usage`——模型上报的用量，例如 `generated_images`、`output_tokens` 和 `total_tokens`。按 token 计费的模型按其中的 token 数计费；按次计费的模型每次请求计费一次

> [!WARNING]
>
> `data[].url` 中的 URL **有效期很短**。请在过期前下载并保存到你自己的存储中。

## 常见 4xx 原因

* `400 InvalidParameter — image size must be at least 3686400 pixels`——`size` 太小。请使用 `1920x1920` 或更大。
* `400 model_route_not_supported`——该模型不走本 endpoint（例如文本模型 `gpt-4.1-mini`）。错误体中的 `supported_routes` 会列出它支持的路由。
* `404 model not found`——网关上不存在该模型 ID（例如已下线的 `seedream-4-5-251128`）。请查阅[模型目录](https://aisa.one/docs/zh/guides/models.md)。
* `400 invalid_request`——`size` 字符串格式不正确（例如写成 `1024` 而不是 `1024x1024`）。

更多内容参见[错误码](https://aisa.one/docs/zh/api-reference/errors.md)和[速率限制](https://aisa.one/docs/zh/api-reference/rate-limits.md)。

## 相关

> [card] [模型目录](https://aisa.one/docs/zh/guides/models.md)
>
> 当前模型 ID 及各自支持的 endpoint。

> [card] [Gemini generateContent](https://aisa.one/docs/zh/api-reference/chat/post_models-model-generatecontent.md)
>
> Gemini 兼容的 generateContent endpoint。

> [card] [Media Gen skill](https://aisa.one/docs/agent-skills/media-gen.md)
>
> 封装图像与视频生成的 Agent 技能。

## 请求规范

* **方法与路径:** POST /v1/images/generations
* **可用状态:** enabled
* **请求 URL 模板:** `https://api.aisa.one/v1/images/generations`
* **X-AISA-Cost-Mode:** header; 可选

[完整 OpenAPI 定义](https://aisa.one/docs/openapi/zh/media-generation.json)

有效请求声明（包括认证和引用的 schema）：

```json theme={null}
{
  "operationId": "createImageGeneration",
  "method": "POST",
  "path": "/v1/images/generations",
  "servers": [
    {
      "url": "https://api.aisa.one"
    }
  ],
  "parameters": [
    {
      "description": "Return a free, read-only cost quote for this caller and payload instead of generating.",
      "in": "header",
      "name": "X-AISA-Cost-Mode",
      "schema": {
        "enum": [
          "quote"
        ],
        "type": "string"
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "examples": {
          "basic": {
            "summary": "Single 2K image",
            "value": {
              "model": "seedream-5-0-260128",
              "n": 1,
              "prompt": "A cute red panda, ultra-detailed, cinematic lighting",
              "size": "2048x2048"
            }
          },
          "batch": {
            "summary": "Four candidates for selection",
            "value": {
              "model": "seedream-5-0-260128",
              "n": 4,
              "prompt": "Oil painting of a rolling hillside at sunset",
              "size": "2048x2048"
            }
          },
          "minimum_size": {
            "summary": "Exactly at minimum allowed size (1920×1920)",
            "value": {
              "model": "seedream-5-0-260128",
              "n": 1,
              "prompt": "A futuristic cyberpunk city, neon lights, rainy night, 8k",
              "size": "1920x1920"
            }
          }
        },
        "schema": {
          "properties": {
            "image": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                }
              ],
              "description": "Reference image(s) for models that start from a picture, as an https or data: URL."
            },
            "model": {
              "description": "An image model from GET /v1/models, for example seedream-5-0-260128, wan2.7-image or gpt-image-2.",
              "minLength": 1,
              "type": "string"
            },
            "n": {
              "default": 1,
              "description": "Number of images, for models that support more than one.",
              "minimum": 1,
              "type": "integer"
            },
            "prompt": {
              "description": "Text description of the image to generate.",
              "minLength": 1,
              "type": "string"
            },
            "size": {
              "description": "WIDTHxHEIGHT, for example 2048x2048. Accepted sizes depend on the model.",
              "example": "2048x2048",
              "type": "string"
            }
          },
          "required": [
            "model",
            "prompt"
          ],
          "type": "object"
        }
      }
    },
    "required": true
  },
  "x-aisa-status": "enabled",
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
```

## 费用与请求规则

价格取决于所选模型。固定价模型每次请求收取一次费用，不随 n 改变；按 token 定价的模型按实际用量收费。 账户适用价格可能不同；支持报价的接口可按实际请求获取报价。


## OpenAPI

````yaml openapi/zh/media-generation.json POST /v1/images/generations
openapi: 3.1.0
info:
  description: >-
    Image and video generation on AIsa models. The model field selects the
    model; GET /v1/models lists the enabled image and video models and the
    routes each one serves.
  title: Media Generation
  version: '1'
  x-aisa-capabilities:
    idempotency: Idempotency-Key
    max_price: X-AISA-Max-Price-USD
    quote:
      header: X-AISA-Cost-Mode
      value: quote
  x-aisa-catalogs:
    media-generation:
      description: >-
        Image and video generation on AIsa models. The model field selects the
        model; GET /v1/models lists the enabled image and video models and the
        routes each one serves.
      title: Media Generation
      x-aisa-capabilities:
        idempotency: Idempotency-Key
        max_price: X-AISA-Max-Price-USD
        quote:
          header: X-AISA-Cost-Mode
          value: quote
      x-aisa-document:
        facts_hash: 91bf641454e0de177731cf163176d280d129e69966cbcc50fec1085b586240bc
        generator_version: '3'
        protocol_version: '1'
        schema_version: '1'
      x-aisa-plans:
        builder: 1
        display_plan: payg
        payg: 1
        similarweb_payg: 1
        team: 1
        version: e70a0959cd1b93b84ae16dffd7a538273ddb9c1d46277b82823c37ff1b6bc0fb
  x-aisa-configured-paths:
    - /v1/images/generations
    - /v1/models
    - /v1/models/{model}
    - /v1/video/generations
    - /v1/video/generations/{task_id}
  x-aisa-document:
    composer_version: '31'
    document_hash: sha256:57822a7aaff281af1eafe18f7aa610c6cd83e7b77a5df5b713b9d88d6f8cf2d2
    facts_hash: 91bf641454e0de177731cf163176d280d129e69966cbcc50fec1085b586240bc
    generator_version: '3'
    protocol_version: '1'
    response_pending: []
    schema_version: '1'
  x-aisa-plans:
    builder: 1
    display_plan: payg
    payg: 1
    similarweb_payg: 1
    team: 1
    version: e70a0959cd1b93b84ae16dffd7a538273ddb9c1d46277b82823c37ff1b6bc0fb
  x-aisa-provider: media-generation
servers:
  - url: https://api.aisa.one
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      summary: Generate images
      description: >-
        Generate images with the OpenAI-compatible images-generations endpoint.


        **Size constraint (Seedream routes only).** 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`. Wan
        and `gpt-image-2` routes accept smaller sizes — `1024x1024` is verified
        working for `wan2.7-image`.


        OpenAI-compatible image generation. The gateway requires model and
        resolves it from the model catalog; the remaining fields are forwarded
        to the selected model, which validates them. Accepted sizes are
        model-specific (Seedream requires at least 3,686,400 pixels, for example
        2048x2048). Images are returned as url or b64_json, as the model
        produces them. With X-AISA-Cost-Mode: quote the route returns a
        cost_estimate instead and generates nothing.
      operationId: createImageGeneration
      parameters:
        - description: >-
            Return a free, read-only cost quote for this caller and payload
            instead of generating.
          in: header
          name: X-AISA-Cost-Mode
          schema:
            enum:
              - quote
            type: string
      requestBody:
        content:
          application/json:
            examples:
              basic:
                summary: Single 2K image
                value:
                  model: seedream-5-0-260128
                  'n': 1
                  prompt: A cute red panda, ultra-detailed, cinematic lighting
                  size: 2048x2048
              batch:
                summary: Four candidates for selection
                value:
                  model: seedream-5-0-260128
                  'n': 4
                  prompt: Oil painting of a rolling hillside at sunset
                  size: 2048x2048
              minimum_size:
                summary: Exactly at minimum allowed size (1920×1920)
                value:
                  model: seedream-5-0-260128
                  'n': 1
                  prompt: A futuristic cyberpunk city, neon lights, rainy night, 8k
                  size: 1920x1920
            schema:
              properties:
                image:
                  anyOf:
                    - type: string
                    - items:
                        type: string
                      type: array
                  description: >-
                    Reference image(s) for models that start from a picture, as
                    an https or data: URL.
                model:
                  description: >-
                    An image model from GET /v1/models, for example
                    seedream-5-0-260128, wan2.7-image or gpt-image-2.
                  minLength: 1
                  type: string
                'n':
                  default: 1
                  description: Number of images, for models that support more than one.
                  minimum: 1
                  type: integer
                prompt:
                  description: 要生成的图像的文本描述。
                  minLength: 1
                  type: string
                size:
                  description: >-
                    WIDTHxHEIGHT, for example 2048x2048. Accepted sizes depend
                    on the model.
                  example: 2048x2048
                  type: string
              required:
                - model
                - prompt
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                additionalProperties: true
                properties:
                  created:
                    type: integer
                  data:
                    items:
                      additionalProperties: true
                      properties:
                        b64_json:
                          description: Base64-encoded image bytes.
                          type: string
                        revised_prompt:
                          type: string
                        url:
                          description: Temporary URL of the image.
                          type: string
                      type: object
                    type: array
                required:
                  - data
                type: object
          description: Generated images.
          headers:
            X-AISA-Customer-Cost-Micros-USD:
              description: >-
                The charge settled for this request, in micro-USD. Omitted for
                requests paid by x402 or MPP, which report payment through that
                protocol.
              schema:
                minimum: 0
                type: integer
        default:
          description: >-
            Validation, authentication, balance or provider error. Provider
            refusals, such as content checks, keep their 4xx status.
components:
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.