生成图片
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "microsoft/mai-image-2.5-pro",
"prompt": "日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。",
"size": "1024x1024"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "microsoft/mai-image-2.5-pro",
"prompt": "日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。",
"size": "1024x1024"
}
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: '日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。',
size: '1024x1024'
})
};
fetch('https://api.tikway.ai/v1/images/generations', 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/generations",
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' => '日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。',
'size' => '1024x1024'
]),
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/generations"
payload := strings.NewReader("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1788923928,
"data": [
{
"index": 0,
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"model": "microsoft/mai-image-2.5-pro",
"output_format": "png",
"size": "1024x1024",
"usage": {
"input_tokens": 36,
"input_tokens_details": {
"text_tokens": 36
},
"output_tokens": 1024,
"output_tokens_details": {
"image_tokens": 1024
},
"total_tokens": 1060
}
}MAI Image
生成图片
microsoft/mai-image-2.5-pro 支持文生图。当前网关暴露 model、prompt、size 和兼容 response_format;模型只生成 1 张 PNG。尺寸的宽、高均至少 768,总像素不超过 1,048,576。
POST
https://api.tikway.ai
/
v1
/
images
/
generations
生成图片
curl --request POST \
--url https://api.tikway.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "microsoft/mai-image-2.5-pro",
"prompt": "日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。",
"size": "1024x1024"
}
'import requests
url = "https://api.tikway.ai/v1/images/generations"
payload = {
"model": "microsoft/mai-image-2.5-pro",
"prompt": "日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。",
"size": "1024x1024"
}
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: '日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。',
size: '1024x1024'
})
};
fetch('https://api.tikway.ai/v1/images/generations', 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/generations",
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' => '日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。',
'size' => '1024x1024'
]),
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/generations"
payload := strings.NewReader("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\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/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"microsoft/mai-image-2.5-pro\",\n \"prompt\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1/images/generations")
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\": \"日落时分的群山景色,夕阳映照山峦与天空,光影柔和,画面自然细腻,具有电影感。\",\n \"size\": \"1024x1024\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1788923928,
"data": [
{
"index": 0,
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
}
],
"model": "microsoft/mai-image-2.5-pro",
"output_format": "png",
"size": "1024x1024",
"usage": {
"input_tokens": 36,
"input_tokens_details": {
"text_tokens": 36
},
"output_tokens": 1024,
"output_tokens_details": {
"image_tokens": 1024
},
"total_tokens": 1060
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
使用 Doubao Seedream 5.0 Pro 根据文字生成图片。
必填。MAI Image 2.5 Pro 的 Forward 模型 ID。
可用选项:
microsoft/mai-image-2.5-pro 必填。图片提示词,原生模型上下文上限 32,000 tokens。
Minimum string length:
1示例:
"一座漂浮在云海上的未来城市,日出时分,电影级光影,建筑细节丰富"
OFOX 兼容尺寸 WIDTHxHEIGHT。MAI Image 2.5 Pro 的宽、高均至少 768,且总像素不超过 1,048,576。
Pattern:
^[1-9]\d*x[1-9]\d*$OFOX 兼容响应格式。MAI 原生输出始终为单张 PNG Base64;建议使用 b64_json。
可用选项:
b64_json, url 响应
200 - application/json
统一转换后的 OpenAI Images 响应。
图片创建时间的 Unix 时间戳,单位为秒。
示例:
1788480000
实际执行请求的模型标识。
实际输出格式。
实际生成尺寸。
本次生成的用量信息。
Hide child attributes
Hide child attributes
输入 token 数。
输出 token 数。
总 token 数。