文档

wan2.7 图片生成与编辑

- 万相 2.7 图像系列,支持文生图、图生图(编辑)、交互式编辑、组图生成与多图参考

  • 万相 2.7 图像系列,支持文生图、图生图(编辑)、交互式编辑、组图生成与多图参考
  • 异步处理模式,提交后返回 task_id,需轮询查询接口获取结果
  • 支持 1K / 2K / 4K 分辨率,wan2.7-image-pro 文生图最高支持 4K
  • 计费按成功生成的图片张数计算,与分辨率和宽高比无关

请求示例

bash curl --request POST \ --url https://api.openveer.com/v1/images/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "wan2.7-image-pro", "prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵" }'

```python
import requests

url = "https://api.openveer.com/v1/images/generations"

payload = {
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}

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

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

print(response.json())
```

```javascript
const url = "https://api.openveer.com/v1/images/generations";

const payload = {
model: "wan2.7-image-pro",
prompt: "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
};

const headers = {
"Authorization": "Bearer ",
"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));
```

```go
package main

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

func main() {
url := "https://api.openveer.com/v1/images/generations"

  payload := map[string]interface{}{
      "model":  "wan2.7-image-pro",
      "prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵",
  }

  jsonData, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
  req.Header.Set("Authorization", "Bearer <token>")
  req.Header.Set("Content-Type", "application/json")

  client := &http.Client{}
  resp, err := client.Do(req)
  if err != nil {
      panic(err)
  }
  defer resp.Body.Close()

  body, _ := ioutil.ReadAll(resp.Body)
  fmt.Println(string(body))

}
```

```java
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.openveer.com/v1/images/generations";

      String payload = """
      {
        "model": "wan2.7-image-pro",
        "prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
      }
      """;

      HttpClient client = HttpClient.newHttpClient();
      HttpRequest request = HttpRequest.newBuilder()
          .uri(URI.create(url))
          .header("Authorization", "Bearer <token>")
          .header("Content-Type", "application/json")
          .POST(HttpRequest.BodyPublishers.ofString(payload))
          .build();

      HttpResponse<String> response = client.send(request,
          HttpResponse.BodyHandlers.ofString());

      System.out.println(response.body());
  }

}
```

```php
"wan2.7-image-pro", "prompt" => "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵" ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Bearer ", "Content-Type: application/json" ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?>

```

```ruby
require 'net/http'
require 'json'
require 'uri'

url = URI("https://api.openveer.com/v1/images/generations")

payload = {
model: "wan2.7-image-pro",
prompt: "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer "
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = http.request(request)
puts response.body
```

```swift
import Foundation

let url = URL(string: "https://api.openveer.com/v1/images/generations")!

let payload: [String: Any] = [
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer ", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error { print("Error: (error)"); return }
if let data = data, let str = String(data: data, encoding: .utf8) { print(str) }
}
task.resume()
```

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
static async Task Main(string[] args)
{
var payload = @"{
""model"": ""wan2.7-image-pro"",
""prompt"": ""一间有着精致窗户的花店,漂亮的木质门,摆放着花朵""
}";

      using var client = new HttpClient();
      client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

      var content = new StringContent(payload, Encoding.UTF8, "application/json");
      var response = await client.PostAsync(
          "https://api.openveer.com/v1/images/generations", content);
      Console.WriteLine(await response.Content.ReadAsStringAsync());
  }

}
```

响应示例

json { "code": "success", "data": [ { "task_id": "task_01HX...", "status": "processing" } ] }

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

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

json { "error": { "code": 402, "message": "账户余额不足,请充值后再试", "type": "payment_required" } }

json { "error": { "code": 429, "message": "请求过于频繁,请稍后再试", "type": "rate_limit_error" } }

json { "error": { "code": 500, "message": "服务器内部错误,请稍后重试", "type": "server_error" } }

Authorizations

Authorization string
所有接口均需要使用 Bearer Token 进行认证 访问 [API Key 管理页面](https://openveer.com) 获取您的 API Key,并在请求头中添加: ``` Authorization: Bearer YOUR_API_KEY ```

可用模型

模型名称 简介 文生图最高分辨率 图像编辑/组图最高分辨率 单价
wan2.7-image-pro 专业版,细节更好,支持 4K 4K 2K ¥0.50 / 张
wan2.7-image 标准版,速度更快 2K 2K ¥0.20 / 张
注意
计费按成功生成的图片张数 × 单价计算,输入不计费,与分辨率和宽高比无关。失败请求不扣费。

Body

model string
图像生成模型名称 可选值: * `wan2.7-image-pro` — 专业版,文生图最高 4K * `wan2.7-image` — 标准版,速度更快,最高 2K
prompt string
图像内容的文字描述,最长 5000 字符 * **文生图模式**(不传 `image_urls`):必填 * **图像编辑模式**(传入 `image_urls`):可选,建议填写以指导编辑效果 示例:`"一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"`
image_urls string
"> 输入图片 URL 数组,用于图像编辑、多图参考等场景 传入后自动进入**图像编辑模式**。 **支持格式:** HTTP / HTTPS 图片链接;`data:image/...;base64,...` Base64 格式 **限制:** 最多 9 张;格式 JPEG / PNG / WEBP / BMP;尺寸 240–8000 px,宽高比 1:8 \~ 8:1;单张 ≤ 20MB
注意
传入图片后,输出宽高比自动与**最后一张**输入图片保持一致。图像编辑模式最高支持 2K,不支持 4K。
n integer
生成图像数量 * **非组图模式**:1–4(默认 1) * **组图模式**(`enable_sequential: true`):1–12(默认 1)
注意
按成功生成的张数计费,会根据 `n` 进行预扣费。
size string
输出分辨率或宽高比,支持三种格式: **① 档位关键字(推荐):** `1K` / `2K`(默认)/ `4K`(仅 `wan2.7-image-pro` 文生图) **② 宽高比:** `1:1` / `16:9` / `9:16` / `4:3` / `3:4` / `3:2` / `2:3`(默认按 2K 换算) **③ 像素值:** `1024x1024` 或 `1024*1024`
resolution string
分辨率档位关键字:`1K` / `2K` / `4K`,可与 `size`(宽高比)配合使用。 | 模型 | 场景 | 支持档位 | 像素范围 | | ------------------ | --------- | :--------------: | -------------------- | | `wan2.7-image-pro` | 文生图(非组图) | 1K / **2K** / 4K | 768×768 \~ 4096×4096 | | `wan2.7-image-pro` | 图像编辑 / 组图 | 1K / **2K** | 768×768 \~ 2048×2048 | | `wan2.7-image` | 所有场景 | 1K / **2K** | 768×768 \~ 2048×2048 |
negative_prompt string
反向提示词,描述不希望出现在图片中的内容 示例:`"模糊、变形、低质量"`
watermark boolean
是否在图片右下角添加 "AI 生成" 水印
seed integer
随机种子,范围 0–2147483647。相同种子在相同参数下可生成风格近似稳定的结果。
thinking_mode boolean
是否开启思考模式。开启后模型增强推理能力,提升画面质量,但耗时增加。
注意
仅在**非组图模式**且**无图片输入**时生效。
enable_sequential boolean
是否启用**组图模式**,一次生成多张内容连贯、风格一致的图片,适合连环画、分镜等场景。 * 开启后 `n` 上限为 12 * 组图模式下 `thinking_mode` 与 `color_palette` 不生效 * `wan2.7-image-pro` 组图模式最高 2K,不支持 4K
bbox_list array
交互式编辑框选区域,用于精确指定编辑或插入位置 **结构:** `[[[x1, y1, x2, y2], ...], ...]` * 外层数组长度必须等于 `image_urls` 长度 * 无需框选的图片传 `[]` 占位 * 单张图片最多 2 个框;坐标为原图绝对像素值,左上角为 (0, 0) 示例:`[[], [[989, 515, 1138, 681]]]`
color_palette string
"> 自定义颜色主题,**仅非组图模式可用** * 3–10 项,建议 8 项;每项包含 `hex`(颜色值)和 `ratio`(占比) * 所有 `ratio` 之和必须等于 `100.00%` ```json [ { "hex": "#C2D1E6", "ratio": "23.51%" }, { "hex": "#636574", "ratio": "76.49%" } ] ```

Response

code string
响应状态,成功时为 `"success"`
data array
任务唯一标识符,用于查询生成结果
status string
任务初始状态,固定为 `processing`

示例

文生图(最简请求)

{
  "model": "wan2.7-image-pro",
  "prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}

文生图(指定分辨率)

{
  "model": "wan2.7-image-pro",
  "prompt": "夏日海滩,蓝天白云,4K 高清",
  "size": "4K",
  "thinking_mode": true
}

文生图(自定义颜色主题)

{
  "model": "wan2.7-image-pro",
  "prompt": "极简风格的现代客厅",
  "size": "2K",
  "color_palette": [
    { "hex": "#C2D1E6", "ratio": "23.51%" },
    { "hex": "#CDD8E9", "ratio": "20.13%" },
    { "hex": "#B5C8DB", "ratio": "15.88%" },
    { "hex": "#C0B5B4", "ratio": "13.27%" },
    { "hex": "#DAE0EC", "ratio": "10.11%" },
    { "hex": "#636574", "ratio": "8.93%" },
    { "hex": "#CACAD2", "ratio": "5.55%" },
    { "hex": "#CBD4E4", "ratio": "2.62%" }
  ]
}

组图生成

{
  "model": "wan2.7-image-pro",
  "prompt": "电影感组图:同一只流浪橘猫,前后特征必须一致。第一张春天樱花树下,第二张夏天老街树荫,第三张秋天落叶满地,第四张冬天雪地脚印。",
  "enable_sequential": true,
  "n": 4,
  "size": "2K"
}

单图编辑

{
  "model": "wan2.7-image",
  "prompt": "把背景换成日落场景,整体偏暖色调",
  "image_urls": ["https://example.com/portrait.jpg"],
  "size": "2K"
}

多图参考 / 元素融合

{
  "model": "wan2.7-image-pro",
  "prompt": "把图2的涂鸦喷绘在图1的汽车上",
  "image_urls": [
    "https://example.com/car.webp",
    "https://example.com/paint.webp"
  ],
  "size": "2K"
}

交互式编辑(框选区域)

通过 bbox_list 精确指定编辑位置,与 image_urls 一一对应,无需框选的图片传 []

{
  "model": "wan2.7-image-pro",
  "prompt": "把图1的闹钟放在图2的框选位置,保持场景和光线融合自然",
  "image_urls": [
    "https://example.com/clock.webp",
    "https://example.com/desk.webp"
  ],
  "bbox_list": [
    [],
    [[989, 515, 1138, 681]]
  ],
  "size": "2K"
}
注意
**查询任务结果** 图像生成为异步任务,提交后返回 `task_id`,请使用 [获取任务状态](/cn/api-reference/tasks/status) 接口轮询直到 `status == completed`。