图片编辑
curl --request POST \
--url https://api.tikway.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "microsoft/mai-image-2.5-pro",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"images": [
{
"image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658"
}
]
}
'import requests
url = "https://api.tikway.ai/v1/images/edits"
payload = {
"model": "microsoft/mai-image-2.5-pro",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"images": [{ "image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658" }]
}
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: 'microsoft/mai-image-2.5-pro',
prompt: 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
size: '1024x1024',
images: [
{
image_url: 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
}
]
})
};
fetch('https://api.tikway.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.tikway.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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'microsoft/mai-image-2.5-pro',
'prompt' => 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
'size' => '1024x1024',
'images' => [
[
'image_url' => 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
]
]
]),
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.tikway.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\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.tikway.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/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\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}MAI Image
图片编辑
microsoft/mai-image-2.5-pro 支持单张 JPEG/PNG 图片编辑。model、images 和 prompt 必填;输出固定为单张 PNG。
POST
https://api.tikway.ai
/
v1
/
images
/
edits
图片编辑
curl --request POST \
--url https://api.tikway.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "microsoft/mai-image-2.5-pro",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"images": [
{
"image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658"
}
]
}
'import requests
url = "https://api.tikway.ai/v1/images/edits"
payload = {
"model": "microsoft/mai-image-2.5-pro",
"prompt": "Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.",
"size": "1024x1024",
"images": [{ "image_url": "https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658" }]
}
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: 'microsoft/mai-image-2.5-pro',
prompt: 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
size: '1024x1024',
images: [
{
image_url: 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
}
]
})
};
fetch('https://api.tikway.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.tikway.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",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'microsoft/mai-image-2.5-pro',
'prompt' => 'Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.',
'size' => '1024x1024',
'images' => [
[
'image_url' => 'https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658'
]
]
]),
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.tikway.ai/v1/images/edits"
payload := strings.NewReader("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\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.tikway.ai/v1/images/edits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/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\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"Keep the apple unchanged and replace only its background with a misty enchanted forest under soft cinematic lighting.\",\n \"size\": \"1024x1024\",\n \"images\": [\n {\n \"image_url\": \"https://gd-hbimg.huaban.com/cb36fdfc6ee4707de3ec666d6bc202fb99d9bef326a10d-oQHn3b_fw658\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
必填。MAI Image 2.5 Pro 的 Forward 模型 ID。
可用选项:
microsoft/mai-image-2.5-pro 必填。期望如何编辑或扩展图像的文字描述。
Minimum string length:
1兼容输出尺寸。MAI 原生编辑接口不提供独立尺寸参数,是否生效取决于 OFOX 上游。
可用选项:
auto, 1024x1024, 1536x1024, 1024x1536, null OFOX 兼容响应格式。MAI 原生输出固定为单张 PNG Base64;建议使用 b64_json。
可用选项:
b64_json, url 响应
200 - application/json
编辑结果创建时的 Unix 时间戳(秒)。
实际采用的输出背景。
可用选项:
transparent, opaque 实际输出格式。
可用选项:
png, webp, jpeg 实际使用的输出质量。
可用选项:
low, medium, high, auto 实际生成的图片尺寸。
GPT Image 模型的 token 用量。
Hide child attributes
Hide child attributes
输入文本和图像的 token 数。
输出 token 数。
输入和输出 token 总数。