编辑图片
curl --request POST \
--url https://api.bianxie.ai/v1/images/editsimport requests
url = "https://api.bianxie.ai/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.bianxie.ai/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.bianxie.ai/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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bianxie.ai/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
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.bianxie.ai/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bianxie.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyOpenAI
编辑图片
使用图片和提示词创建编辑结果
POST
/
v1
/
images
/
edits
编辑图片
curl --request POST \
--url https://api.bianxie.ai/v1/images/editsimport requests
url = "https://api.bianxie.ai/v1/images/edits"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.bianxie.ai/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.bianxie.ai/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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.bianxie.ai/v1/images/edits"
req, _ := http.NewRequest("POST", url, nil)
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.bianxie.ai/v1/images/edits")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bianxie.ai/v1/images/edits")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body请求使用
响应结构与图片生成接口一致。不要手动设置 multipart boundary;让 HTTP 客户端生成。默认不支持流式输出。
multipart/form-data。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | file/file[] | 是 | 待编辑图片。格式、尺寸和数量受模型限制。 |
prompt | string | 是 | 期望的编辑结果。 |
model | string | 是 | 图片编辑模型 ID。 |
mask | file | 否 | 指示可编辑区域的遮罩。 |
n, size, quality | mixed | 否 | 数量、尺寸与质量。 |
background, output_format | string | 否 | 背景与输出格式。 |
user | string | 否 | 终端用户标识。 |
curl https://api.bianxie.ai/v1/images/edits \
-H "Authorization: Bearer API_KEY" \
-F "model=your-model" \
-F "prompt=添加一顶红色帽子" \
-F "image=@input.png"
client.images.edit(model="your-model", image=open("input.png", "rb"), prompt="添加一顶红色帽子")
await client.images.edit({ model: "your-model", image: fs.createReadStream("input.png"), prompt: "Add a red hat" });
⌘I
