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

# Z-Image-Turbo 图像生成

>  - 异步处理模式，返回任务ID用于后续查询
- 轻量快速图片生成，支持中英双语
- 支持 1K/2K 分辨率档位，支持智能改写提示词 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/images/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "z-image-turbo",
      "prompt": "水墨画风格的山水风景"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.apimart.ai/v1/images/generations"

  payload = {
      "model": "z-image-turbo",
      "prompt": "水墨画风格的山水风景"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/images/generations";

  const payload = {
    model: "z-image-turbo",
    prompt: "水墨画风格的山水风景",
  };

  const headers = {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload),
  })
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01JGXYZ1234567890ABCDEF"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "请求参数无效",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "身份验证失败，请检查您的API密钥",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "账户余额不足，请充值后再试",
      "type": "payment_required"
    }
  }
  ```
</ResponseExample>

## 支持的模型

| 模型名             | 说明              | 生成张数   | 计费方式 |
| --------------- | --------------- | ------ | ---- |
| `z-image-turbo` | 轻量快速图片生成，支持中英双语 | 固定 1 张 | 固定价格 |

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用Bearer Token进行认证

  获取 API Key：

  访问 [API Key 管理页面](https://apimart.ai/keys) 获取您的 API Key

  使用时在请求头中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" required>
  模型名称

  * `z-image-turbo` - 轻量快速图片生成，支持中英双语
</ParamField>

<ParamField body="prompt" type="string" required>
  图像生成的文本描述，最多 800 字符
</ParamField>

<ParamField body="size" type="string" default="1:1">
  图像宽高比

  支持的宽高比：

  * `1:1` - 正方形（默认）
  * `4:3` - 横向 4:3
  * `3:4` - 纵向 3:4
  * `16:9` - 横向宽屏
  * `9:16` - 纵向竖屏
  * `3:2` - 横向 3:2
  * `2:3` - 纵向 2:3
</ParamField>

<ParamField body="resolution" type="string" default="1K">
  分辨率档位

  * `1K` - 标准分辨率（默认）
  * `2K` - 高清分辨率
</ParamField>

<ParamField body="prompt_extend" type="boolean" default="false">
  智能改写提示词

  开启后，AI 会自动优化提示词，生成效果更好，费用会有所增加。

  * `false` - 关闭（默认）
  * `true` - 开启
</ParamField>

## 尺寸对照表

通过 `size`（比例）+ `resolution`（分辨率档位）组合控制输出尺寸。

| 比例     | 1K 档位     | 2K 档位     |
| ------ | --------- | --------- |
| `1:1`  | 1024×1024 | 2048×2048 |
| `4:3`  | 1152×864  | 2048×1536 |
| `3:4`  | 864×1152  | 1536×2048 |
| `16:9` | 1280×720  | 2048×1152 |
| `9:16` | 720×1280  | 1152×2048 |
| `3:2`  | 1248×832  | 2048×1360 |
| `2:3`  | 832×1248  | 1360×2048 |

## 使用场景示例

**基础文生图（最简请求）**

```json theme={null}
{
  "model": "z-image-turbo",
  "prompt": "水墨画风格的山水风景"
}
```

**指定比例和分辨率**

```json theme={null}
{
  "model": "z-image-turbo",
  "prompt": "极简主义风格的咖啡厅室内设计",
  "size": "16:9",
  "resolution": "2K"
}
```

**开启智能改写**

```json theme={null}
{
  "model": "z-image-turbo",
  "prompt": "一只猫",
  "prompt_extend": true
}
```

## Response

<ResponseField name="code" type="integer">
  响应状态码
</ResponseField>

<ResponseField name="data" type="array">
  返回数据数组

  <Expandable title="属性">
    <ResponseField name="status" type="string">
      任务状态

      * `submitted` - 已提交
    </ResponseField>

    <ResponseField name="task_id" type="string">
      任务唯一标识符
    </ResponseField>
  </Expandable>
</ResponseField>

## 注意事项

1. **异步处理**：提交后返回 `task_id`，需轮询 `/v1/tasks/{task_id}` 获取结果
2. **图片存储**：生成的图片已镜像到平台 CDN，长期有效
3. **计费规则**：按成功生成的图片张数计费，失败不扣费
4. **固定张数**：Z-Image-Turbo 固定每次生成 1 张，不支持 `n` 参数
