curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "wan2.7-image-pro",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/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))
}
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.apimart.ai/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
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "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 <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/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 <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", 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()
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.apimart.ai/v1/images/generations", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
{
"code": "success",
"data": [
{
"task_id": "task_01HX...",
"status": "processing"
}
]
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
wan2.7-image
wan2.7 图片生成与编辑
- 万相 2.7 图像系列,支持文生图、图生图(编辑)、交互式编辑、组图生成与多图参考
- 异步处理模式,提交后返回 task_id,需轮询查询接口获取结果
- 支持 1K / 2K / 4K 分辨率,
wan2.7-image-pro文生图最高支持 4K - 计费按成功生成的图片张数计算,与分辨率和宽高比无关
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "wan2.7-image-pro",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/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))
}
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.apimart.ai/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
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "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 <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/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 <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", 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()
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.apimart.ai/v1/images/generations", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
{
"code": "success",
"data": [
{
"task_id": "task_01HX...",
"status": "processing"
}
]
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}'
import requests
url = "https://api.apimart.ai/v1/images/generations"
payload = {
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/images/generations";
const payload = {
model: "wan2.7-image-pro",
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));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/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))
}
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.apimart.ai/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
$url = "https://api.apimart.ai/v1/images/generations";
$payload = [
"model" => "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 <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/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 <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/images/generations")!
let payload: [String: Any] = [
"model": "wan2.7-image-pro",
"prompt": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", 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()
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.apimart.ai/v1/images/generations", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
{
"code": "success",
"data": [
{
"task_id": "task_01HX...",
"status": "processing"
}
]
}
{
"error": {
"code": 400,
"message": "请求参数无效",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "身份验证失败,请检查您的API密钥",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "账户余额不足,请充值后再试",
"type": "payment_required"
}
}
{
"error": {
"code": 429,
"message": "请求过于频繁,请稍后再试",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "服务器内部错误,请稍后重试",
"type": "server_error"
}
}
Authorizations
可用模型
| 模型名称 | 简介 | 文生图最高分辨率 | 图像编辑/组图最高分辨率 | 单价 |
|---|---|---|---|---|
wan2.7-image-pro | 专业版,细节更好,支持 4K | 4K | 2K | ¥0.50 / 张 |
wan2.7-image | 标准版,速度更快 | 2K | 2K | ¥0.20 / 张 |
计费按成功生成的图片张数 × 单价计算,输入不计费,与分辨率和宽高比无关。失败请求不扣费。
Body
图像生成模型名称可选值:
wan2.7-image-pro— 专业版,文生图最高 4Kwan2.7-image— 标准版,速度更快,最高 2K
图像内容的文字描述,最长 5000 字符
- 文生图模式(不传
image_urls):必填 - 图像编辑模式(传入
image_urls):可选,建议填写以指导编辑效果
"一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"输入图片 URL 数组,用于图像编辑、多图参考等场景传入后自动进入图像编辑模式。支持格式: HTTP / HTTPS 图片链接;
data:image/...;base64,... Base64 格式限制: 最多 9 张;格式 JPEG / PNG / WEBP / BMP;尺寸 240–8000 px,宽高比 1:8 ~ 8:1;单张 ≤ 20MB传入图片后,输出宽高比自动与最后一张输入图片保持一致。图像编辑模式最高支持 2K,不支持 4K。
生成图像数量
- 非组图模式:1–4(默认 1)
- 组图模式(
enable_sequential: true):1–12(默认 1)
按成功生成的张数计费,会根据
n 进行预扣费。输出分辨率或宽高比,支持三种格式:① 档位关键字(推荐):
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分辨率档位关键字:
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 |
反向提示词,描述不希望出现在图片中的内容示例:
"模糊、变形、低质量"是否在图片右下角添加 “AI 生成” 水印
随机种子,范围 0–2147483647。相同种子在相同参数下可生成风格近似稳定的结果。
是否开启思考模式。开启后模型增强推理能力,提升画面质量,但耗时增加。
仅在非组图模式且无图片输入时生效。
是否启用组图模式,一次生成多张内容连贯、风格一致的图片,适合连环画、分镜等场景。
- 开启后
n上限为 12 - 组图模式下
thinking_mode与color_palette不生效 wan2.7-image-pro组图模式最高 2K,不支持 4K
交互式编辑框选区域,用于精确指定编辑或插入位置结构:
[[[x1, y1, x2, y2], ...], ...]- 外层数组长度必须等于
image_urls长度 - 无需框选的图片传
[]占位 - 单张图片最多 2 个框;坐标为原图绝对像素值,左上角为 (0, 0)
[[], [[989, 515, 1138, 681]]]自定义颜色主题,仅非组图模式可用
- 3–10 项,建议 8 项;每项包含
hex(颜色值)和ratio(占比) - 所有
ratio之和必须等于100.00%
[
{ "hex": "#C2D1E6", "ratio": "23.51%" },
{ "hex": "#636574", "ratio": "76.49%" }
]
Response
响应状态,成功时为
"success"示例
文生图(最简请求)
{
"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,请使用 获取任务状态 接口轮询直到 status == completed。⌘I