Image-01 文生图
curl --request POST \
--url https://api.powertokens.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "image-01",
"prompt": "A cinematic sunrise over a calm harbor",
"aspect_ratio": "16:9",
"response_format": "base64",
"seed": 0,
"n": 1,
"prompt_optimizer": false
}
'import requests
url = "https://api.powertokens.ai/v1/images/generations"
payload = {
"model": "image-01",
"prompt": "A cinematic sunrise over a calm harbor",
"aspect_ratio": "16:9",
"response_format": "base64",
"seed": 0,
"n": 1,
"prompt_optimizer": False
}
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: 'image-01',
prompt: 'A cinematic sunrise over a calm harbor',
aspect_ratio: '16:9',
response_format: 'base64',
seed: 0,
n: 1,
prompt_optimizer: false
})
};
fetch('https://api.powertokens.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.powertokens.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' => 'image-01',
'prompt' => 'A cinematic sunrise over a calm harbor',
'aspect_ratio' => '16:9',
'response_format' => 'base64',
'seed' => 0,
'n' => 1,
'prompt_optimizer' => false
]),
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.powertokens.ai/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\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.powertokens.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.powertokens.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\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
],
"metadata": {
"provider_request_id": "<string>",
"provider_status_code": 123,
"provider_status_msg": "<string>",
"success_count": 123,
"failed_count": 123
}
}{
"error": {
"message": "请求体格式错误或字段取值非法",
"type": "invalid_request_error",
"code": "bad_request_body"
}
}{
"error": {
"message": "无效的令牌",
"type": "api_error",
"code": "access_denied"
}
}{
"error": {
"message": "请求体过大,请缩小输入后重试",
"type": "api_error",
"code": "read_request_body_failed"
}
}{
"error": {
"message": "当前账户额度不足,请稍后重试",
"type": "api_error",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "服务内部处理失败,请稍后重试",
"type": "api_error",
"code": "gen_relay_info_failed"
}
}{
"error": {
"message": "上游服务返回了无效响应",
"type": "api_error",
"code": "bad_response_status_code"
}
}{
"error": {
"message": "当前模型暂时无可用渠道,请稍后重试",
"type": "api_error",
"code": "get_channel_failed"
}
}MiniMax
Image-01 文生图
适用于 image-01 模型的文生图能力。
公开字段:model、prompt、aspect_ratio、width、height、response_format、seed、n、prompt_optimizer。
POST
/
v1
/
images
/
generations
Image-01 文生图
curl --request POST \
--url https://api.powertokens.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "image-01",
"prompt": "A cinematic sunrise over a calm harbor",
"aspect_ratio": "16:9",
"response_format": "base64",
"seed": 0,
"n": 1,
"prompt_optimizer": false
}
'import requests
url = "https://api.powertokens.ai/v1/images/generations"
payload = {
"model": "image-01",
"prompt": "A cinematic sunrise over a calm harbor",
"aspect_ratio": "16:9",
"response_format": "base64",
"seed": 0,
"n": 1,
"prompt_optimizer": False
}
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: 'image-01',
prompt: 'A cinematic sunrise over a calm harbor',
aspect_ratio: '16:9',
response_format: 'base64',
seed: 0,
n: 1,
prompt_optimizer: false
})
};
fetch('https://api.powertokens.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.powertokens.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' => 'image-01',
'prompt' => 'A cinematic sunrise over a calm harbor',
'aspect_ratio' => '16:9',
'response_format' => 'base64',
'seed' => 0,
'n' => 1,
'prompt_optimizer' => false
]),
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.powertokens.ai/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\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.powertokens.ai/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.powertokens.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\": \"image-01\",\n \"prompt\": \"A cinematic sunrise over a calm harbor\",\n \"aspect_ratio\": \"16:9\",\n \"response_format\": \"base64\",\n \"seed\": 0,\n \"n\": 1,\n \"prompt_optimizer\": false\n}"
response = http.request(request)
puts response.read_body{
"created": 123,
"data": [
{
"url": "<string>",
"b64_json": "<string>"
}
],
"metadata": {
"provider_request_id": "<string>",
"provider_status_code": 123,
"provider_status_msg": "<string>",
"success_count": 123,
"failed_count": 123
}
}{
"error": {
"message": "请求体格式错误或字段取值非法",
"type": "invalid_request_error",
"code": "bad_request_body"
}
}{
"error": {
"message": "无效的令牌",
"type": "api_error",
"code": "access_denied"
}
}{
"error": {
"message": "请求体过大,请缩小输入后重试",
"type": "api_error",
"code": "read_request_body_failed"
}
}{
"error": {
"message": "当前账户额度不足,请稍后重试",
"type": "api_error",
"code": "insufficient_user_quota"
}
}{
"error": {
"message": "服务内部处理失败,请稍后重试",
"type": "api_error",
"code": "gen_relay_info_failed"
}
}{
"error": {
"message": "上游服务返回了无效响应",
"type": "api_error",
"code": "bad_response_status_code"
}
}{
"error": {
"message": "当前模型暂时无可用渠道,请稍后重试",
"type": "api_error",
"code": "get_channel_failed"
}
}授权
在请求头中传入 Authorization: Bearer <token>。
请求体
application/json
模型名称。可选值:image-01
可用选项:
image-01 图像的文本描述,最长 1500 字符
Maximum string length:
1500图像宽高比,默认为 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
必填范围:
512 <= x <= 2048必须是以下数值的倍数 8生成图片的高度(像素)。仅当 model 为 image-01 时生效。注意:width 和 height
需同时设置,取值范围[512, 2048],且必须是 8 的倍数。若与 aspect_ratio 同时设置,则优先使用
aspect_ratio
必填范围:
512 <= x <= 2048必须是以下数值的倍数 8返回图片的形式,默认为 url。可选值:url, base64。 ⚠️ 注意:url 的有效期为 24 小时
可用选项:
url, base64 随机种子。使用相同的 seed 和参数,可以生成内容相近的图片,用于复现结果。如未提供,算法会对 n 张图单独生成随机种子
单次请求生成的图片数量,取值范围[1, 9],默认为 1
必填范围:
1 <= x <= 9是否开启 prompt 自动优化,默认为 false.
⌘I