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

# Z-Image LoRA Pro API：根据文字生成色彩鲜明的图像

> 专业文生图生成 API，支持生动细节优化、灵活尺寸和纵横比控制

## 概览

Z-Image LoRA Pro 是一个异步文生图模型，用于根据提示生成单个高细节图像。它针对生动的场景进行了优化，支持显式 `size` 输入、通用 `aspect_ratio` 预设、可选种子控制和提示扩展。

| 功能 | 值 |
| - | - |
| 模型 ID | `z-image-LoRA-pro` |
| 模式 | `text-to-image` |
| 默认模式 | `text-to-image` |
| 默认尺寸 | `1024*1024` |
| 尺寸格式 | `WIDTH*HEIGHT`, `WIDTHxHEIGHT`, `WIDTHXHEIGHT` |
| 尺寸范围 | 每条边必须在 `256` 和 `2560` 像素之间 |
| 纵横比 | `1:1`, `2:3`, `3:2`, `3:4`, `4:3`, `9:16`, `16:9` |
| 提示扩展 | `prompt_extend`，默认`false` |

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/z-image-LoRA-pro` | 提交文本转图像任务 |
| `GET` | `/statusTask/z-image-LoRA-pro?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/z-image-LoRA-pro" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-image",
      "prompt": "a cinematic portrait with vivid fabric texture, dramatic lighting, and sharp micro details",
      "aspect_ratio": "16:9",
      "prompt_extend": false
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/z-image-LoRA-pro?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/image.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;
```

## 请求体

### 以纵横比生成

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a cinematic portrait with vivid fabric texture, dramatic lighting, and sharp micro details",
    "aspect_ratio": "16:9",
    "prompt_extend": false
  }
}
```

### 生成明确的大小

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-image",
    "prompt": "a vivid product poster with glass reflections and crisp studio lighting",
    "size": "1024*1024",
    "seed": 42,
    "prompt_extend": false
  }
}
```

## 参数

**request\_type** `string` *required* (default: async)

结果交付模式：使用 `async` 并通过 `statusTask` 进行轮询

**input** `object` *required*

Z-Image LoRA Pro 的输入参数。

**属性**

**mode** `string` (default: text-to-image)

生成模式。该模型仅支持`text-to-image`。如果 SDK 助手未指定，则 APIXO 使用 `text-to-image`。

**prompt** `string` *required*

提示文本用于描述要生成的图像。包含主题、场景、材质细节、灯光和构图，可获得更佳效果。最大长度为4000个字符。

**size** `string` (default: 1024\*1024)

可选的显式输出尺寸。支持 `WIDTH*HEIGHT`、`WIDTHxHEIGHT` 和 `WIDTHXHEIGHT` 格式，例如 `1024*1024`、`1024x1024` 或 `1024X1024`。宽度和高度必须在 `256` 到 `2560` 之间。当提供 `size` 时，将优先于 `aspect_ratio`。

**aspect\_ratio** `string` (default: 1:1)

未提供 `size` 时使用的输出纵横比。支持的值为：`1:1`、`2:3`、`3:2`、`3:4`、`4:3`、`9:16`、`16:9`。

**seed** `integer`

可选的随机种子。若要提高实验的可复现性，请指定一个固定的非负整数。

**prompt\_extend** `boolean` (default: false)

是否启用提示扩展。提示扩展不会产生额外的公共费用。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/z-image-LoRA-pro` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

当 `state` 为 `success` 时返回。解析此 JSON 字符串后，可从 `resultUrls` 读取生成的图片链接。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理耗时，以毫秒为单位。有计时数据时返回。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

Z-Image LoRA Pro 按生成的图像数量计费。

| 单位 | APIXO 价格 |
| - | - |
| 生成一张图像 | `$0.025 / image` |

提示词扩写不额外收费。

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

Z-Image LoRA Pro 任务为异步处理。实际延迟会因提示复杂度和当前队列负载而异。

| 使用案例 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| 标准生成 | 任务创建 10 秒后 | 5s-10s |

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 尺寸规则

* 如果未提供 `size` 和 `aspect_ratio`，默认输出尺寸为 `1024*1024`。
* `size` 支持 `*`、`x` 和 `X` 分隔符。
* `size` 优先于 `aspect_ratio`。
* 显式指定 `size` 时，宽度和高度必须保持在 `256-2560` 范围内。
* `aspect_ratio` 仅在未提供 `size` 时使用。
* 支持的 `aspect_ratio` 值映射到平台管理的输出尺寸，且在允许范围内。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、参数类型或值无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `404` | 未找到任务 | 验证 `taskId` 和模型 ID |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误或未知任务失败 | 逐步延长间隔后重试 |
| `502` | 模型服务错误 | 逐步延长间隔后重试 |
| `504` | 模型服务超时 | 稍后重试或再次轮询 |

### 请求验证

| 条件 | 后端行为 |
| - | - |
| `mode` 无效 | 返回模式验证错误；请使用 `text-to-image` |
| 缺失或为空 `prompt` | 返回缺少参数或验证错误 |
| `size`格式无效 | 返回尺寸格式验证错误 |
| 每侧 `size` 外侧 `256-2560` | 返回尺寸范围验证错误 |
| 不支持的 `aspect_ratio` 值 | 返回支持的宽高比列表 |
| 负`seed` | 返回种子验证错误 |

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/image/z-image-lora-pro.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [图像模型](https://apixo.ai/docs/zh/models/image)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [API定价](https://apixo.ai/pricing/api)


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