文生图
curl --request POST \
--url https://api.powertokens.ai/minimax/v1/image_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "image-01",
"prompt": "A man in a white t-shirt, full-body, standing front view, outdoors,\nwith the Venice Beach sign in the background, Los Angeles. Fashion\nphotography in 90s documentary style, film grain, photorealistic.",
"aspect_ratio": "16:9",
"response_format": "url",
"n": 3,
"prompt_optimizer": true
}
'import requests
url = "https://api.powertokens.ai/minimax/v1/image_generation"
payload = {
"model": "image-01",
"prompt": "A man in a white t-shirt, full-body, standing front view, outdoors,
with the Venice Beach sign in the background, Los Angeles. Fashion
photography in 90s documentary style, film grain, photorealistic.",
"aspect_ratio": "16:9",
"response_format": "url",
"n": 3,
"prompt_optimizer": True
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'image-01',
prompt: 'A man in a white t-shirt, full-body, standing front view, outdoors,\nwith the Venice Beach sign in the background, Los Angeles. Fashion\nphotography in 90s documentary style, film grain, photorealistic.',
aspect_ratio: '16:9',
response_format: 'url',
n: 3,
prompt_optimizer: true
})
};
fetch('https://api.powertokens.ai/minimax/v1/image_generation', 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.powertokens.ai/minimax/v1/image_generation",
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' => 'image-01',
'prompt' => 'A man in a white t-shirt, full-body, standing front view, outdoors,
with the Venice Beach sign in the background, Los Angeles. Fashion
photography in 90s documentary style, film grain, photorealistic.',
'aspect_ratio' => '16:9',
'response_format' => 'url',
'n' => 3,
'prompt_optimizer' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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.powertokens.ai/minimax/v1/image_generation"
payload := strings.NewReader("{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
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.powertokens.ai/minimax/v1/image_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.powertokens.ai/minimax/v1/image_generation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "03ff3cd0820949eb8a410056b5f21d38",
"data": {
"image_urls": [
"XXX",
"XXX",
"XXX"
]
},
"metadata": {
"failed_count": "0",
"success_count": "3"
},
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}minimax兼容API
文生图
POST
/
minimax
/
v1
/
image_generation
文生图
curl --request POST \
--url https://api.powertokens.ai/minimax/v1/image_generation \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '
{
"model": "image-01",
"prompt": "A man in a white t-shirt, full-body, standing front view, outdoors,\nwith the Venice Beach sign in the background, Los Angeles. Fashion\nphotography in 90s documentary style, film grain, photorealistic.",
"aspect_ratio": "16:9",
"response_format": "url",
"n": 3,
"prompt_optimizer": true
}
'import requests
url = "https://api.powertokens.ai/minimax/v1/image_generation"
payload = {
"model": "image-01",
"prompt": "A man in a white t-shirt, full-body, standing front view, outdoors,
with the Venice Beach sign in the background, Los Angeles. Fashion
photography in 90s documentary style, film grain, photorealistic.",
"aspect_ratio": "16:9",
"response_format": "url",
"n": 3,
"prompt_optimizer": True
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'image-01',
prompt: 'A man in a white t-shirt, full-body, standing front view, outdoors,\nwith the Venice Beach sign in the background, Los Angeles. Fashion\nphotography in 90s documentary style, film grain, photorealistic.',
aspect_ratio: '16:9',
response_format: 'url',
n: 3,
prompt_optimizer: true
})
};
fetch('https://api.powertokens.ai/minimax/v1/image_generation', 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.powertokens.ai/minimax/v1/image_generation",
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' => 'image-01',
'prompt' => 'A man in a white t-shirt, full-body, standing front view, outdoors,
with the Venice Beach sign in the background, Los Angeles. Fashion
photography in 90s documentary style, film grain, photorealistic.',
'aspect_ratio' => '16:9',
'response_format' => 'url',
'n' => 3,
'prompt_optimizer' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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.powertokens.ai/minimax/v1/image_generation"
payload := strings.NewReader("{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
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.powertokens.ai/minimax/v1/image_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.powertokens.ai/minimax/v1/image_generation")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"image-01\",\n \"prompt\": \"A man in a white t-shirt, full-body, standing front view, outdoors,\\nwith the Venice Beach sign in the background, Los Angeles. Fashion\\nphotography in 90s documentary style, film grain, photorealistic.\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"url\",\n \"n\": 3,\n \"prompt_optimizer\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "03ff3cd0820949eb8a410056b5f21d38",
"data": {
"image_urls": [
"XXX",
"XXX",
"XXX"
]
},
"metadata": {
"failed_count": "0",
"success_count": "3"
},
"base_resp": {
"status_code": 0,
"status_msg": "success"
}
}授权
在请求头中传入 Authorization: Bearer <token>。
请求头
请求体的媒介类型,请设置为 application/json 确保请求数据的格式为 JSON.
可用选项:
application/json 请求体
application/json
模型名称。可选值:image-01
可用选项:
image-01 图像的文本描述,最长 1500 字符
画风设置,仅当 model 为 image-01-live 时生效
Show child attributes
Show child attributes
图像宽高比,默认为 1:1。可选值:
1:1(1024x1024)16:9(1280x720)4:3(1152x864)3:2(1248x832)2:3(832x1248)3:4(864x1152)9:16(720x1280)21:9(1344x576) (仅适用于image-01)
可用选项:
1:1, 16:9, 4:3, 3:2, 2:3, 3:4, 9:16, 21:9 生成图片的宽度(像素)。仅当 model 为 image-01 时生效。注意:width 和 height
需同时设置,取值范围[512, 2048],且必须是 8 的倍数。若与 aspect_ratio 同时设置,则优先使用
aspect_ratio
生成图片的高度(像素)。仅当 model 为 image-01 时生效。注意:width 和 height
需同时设置,取值范围[512, 2048],且必须是 8 的倍数。若与 aspect_ratio 同时设置,则优先使用
aspect_ratio
返回图片的形式,默认为 url。可选值:url, base64。 ⚠️ 注意:url 的有效期为 24 小时
可用选项:
url, base64 随机种子。使用相同的 seed 和参数,可以生成内容相近的图片,用于复现结果。如未提供,算法会对 n 张图单独生成随机种子
单次请求生成的图片数量,取值范围[1, 9],默认为 1
必填范围:
1 <= x <= 9是否开启 prompt 自动优化,默认为 false.
是否在生成的图片中添加水印,默认为 false
⌘I