图片编辑
curl --request POST \
--url https://api.chenyu.cn/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"image": {},
"images": [
{}
],
"mask": {},
"prompt": "<string>",
"size": "<string>",
"n": 123
}
'import requests
url = "https://api.chenyu.cn/v1/images/edits"
payload = {
"model": "<string>",
"image": {},
"images": [{}],
"mask": {},
"prompt": "<string>",
"size": "<string>",
"n": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
image: {},
images: [{}],
mask: {},
prompt: '<string>',
size: '<string>',
n: 123
})
};
fetch('https://api.chenyu.cn/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chenyu.cn/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'image' => [
],
'images' => [
[
]
],
'mask' => [
],
'prompt' => '<string>',
'size' => '<string>',
'n' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.chenyu.cn/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chenyu.cn/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chenyu.cn/v1/images/edits")
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 = "{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>"
}
]
}直接 API 调用
图片编辑
上传图片并按提示词编辑
POST
/
v1
/
images
/
edits
图片编辑
curl --request POST \
--url https://api.chenyu.cn/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"image": {},
"images": [
{}
],
"mask": {},
"prompt": "<string>",
"size": "<string>",
"n": 123
}
'import requests
url = "https://api.chenyu.cn/v1/images/edits"
payload = {
"model": "<string>",
"image": {},
"images": [{}],
"mask": {},
"prompt": "<string>",
"size": "<string>",
"n": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
image: {},
images: [{}],
mask: {},
prompt: '<string>',
size: '<string>',
n: 123
})
};
fetch('https://api.chenyu.cn/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chenyu.cn/v1/images/edits",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'image' => [
],
'images' => [
[
]
],
'mask' => [
],
'prompt' => '<string>',
'size' => '<string>',
'n' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.chenyu.cn/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.chenyu.cn/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chenyu.cn/v1/images/edits")
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 = "{\n \"model\": \"<string>\",\n \"image\": {},\n \"images\": [\n {}\n ],\n \"mask\": {},\n \"prompt\": \"<string>\",\n \"size\": \"<string>\",\n \"n\": 123\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>"
}
]
}图片编辑
使用 OpenAI Images Edit 兼容格式编辑图片。请求支持multipart/form-data 文件上传,也支持 JSON 中传图片资源地址。
JSON 请求里的图片字段可以直接传资源字符串:公网 URL、
data:image/<format>;base64,<data> 或 asset://asset_xxx。需要在提示词中引用某张素材时,使用 { "uri": "...", "label": "原图" }。本地文件可直接使用 multipart/form-data 上传,也可以先调用 上传资源 获取 asset_uri 后再提交 JSON。请求参数
图片编辑模型 ID
待编辑图片。
multipart/form-data 请求中使用文件;JSON 请求中可传资源字符串:公网 URL、data URL 或 asset://asset_xxx。需要在 prompt 中引用时,可传 { "uri": "...", "label": "原图" }多张待编辑图片。数组元素支持与
image 相同的 JSON 写法;每个对象可以设置不同 label蒙版图片。支持文件、公网 URL、data URL 和
asset://asset_xxx编辑提示词
输出图片尺寸,例如
1024x1024生成图片数量
响应参数
创建时间戳
代码示例
import requests
url = "https://api.chenyu.cn/v1/images/edits"
headers = {"Authorization": "Bearer your_api_key"}
data = {
"model": "doubao-seedream-5-0-lite-260128",
"prompt": "把背景改成浅蓝色,保持主体不变",
"size": "1024x1024"
}
files = {
"image": open("input.png", "rb")
}
response = requests.post(url, headers=headers, data=data, files=files)
print(response.json()["data"][0]["url"])
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const form = new FormData();
form.append('model', 'doubao-seedream-5-0-lite-260128');
form.append('prompt', '把背景改成浅蓝色,保持主体不变');
form.append('size', '1024x1024');
form.append('image', fs.createReadStream('input.png'));
axios.post('https://api.chenyu.cn/v1/images/edits', form, {
headers: {
Authorization: 'Bearer your_api_key',
...form.getHeaders()
}
}).then((response) => {
console.log(response.data.data[0].url);
});
curl -X POST "https://api.chenyu.cn/v1/images/edits" \
-H "Authorization: Bearer your_api_key" \
-F "model=doubao-seedream-5-0-lite-260128" \
-F "prompt=把背景改成浅蓝色,保持主体不变" \
-F "size=1024x1024" \
-F "image=@input.png"
JSON 图片资源示例
{
"model": "doubao-seedream-5-0-lite-260128",
"prompt": "把背景改成浅蓝色,保持主体不变",
"size": "1024x1024",
"image": "asset://asset_input_image"
}
{
"model": "doubao-seedream-5-0-lite-260128",
"prompt": "保留 @原图 的主体,把背景改成浅蓝色",
"size": "1024x1024",
"image": {
"uri": "asset://asset_input_image",
"label": "原图"
}
}
响应示例
{
"created": 1780000000,
"data": [
{
"url": "https://example.com/edited.png"
}
]
}
⌘I