curl --request POST \
--url https://api.minimax.cn/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "MiniMax-H3-Image",
"prompt": "一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感",
"size": "2720x1536",
"n": 2,
"response_format": "url"
}
'import requests
url = "https://api.minimax.cn/v1/images/generations"
payload = {
"model": "MiniMax-H3-Image",
"prompt": "一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感",
"size": "2720x1536",
"n": 2,
"response_format": "url"
}
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: 'MiniMax-H3-Image',
prompt: '一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感',
size: '2720x1536',
n: 2,
response_format: 'url'
})
};
fetch('https://api.minimax.cn/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.minimax.cn/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' => 'MiniMax-H3-Image',
'prompt' => '一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感',
'size' => '2720x1536',
'n' => 2,
'response_format' => 'url'
]),
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.minimax.cn/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\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.minimax.cn/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimax.cn/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\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1792308678,
"data": [
{
"url": "https://example.com/h3-image/output-0.jpg",
"size": "2720x1536",
"revised_prompt": "午后的暖光透过木质窗框洒在窗台上,一只橘猫侧身趴着晒太阳,眯着眼睛,毛发被阳光勾出金色轮廓,背景是虚化的室内绿植,胶片颗粒质感,柔和的暖色调"
},
{
"error": {
"code": "1027",
"message": "output image failed content safety check"
}
}
],
"output_format": "jpeg",
"usage": {
"generated_images": 1,
"total_tokens": 7254,
"input_tokens": 3174,
"output_tokens": 4080,
"input_tokens_details": {
"text_tokens": 3174,
"image_tokens": 0
},
"output_tokens_details": {
"image_tokens": 4080
}
},
"request_id": "021792308678142a2c883cf675b9804d"
}文生图
使用 MiniMax-H3-Image 根据文本描述生成图片,支持 auto 或自定义宽高,单次最多生成 10 张。
curl --request POST \
--url https://api.minimax.cn/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "MiniMax-H3-Image",
"prompt": "一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感",
"size": "2720x1536",
"n": 2,
"response_format": "url"
}
'import requests
url = "https://api.minimax.cn/v1/images/generations"
payload = {
"model": "MiniMax-H3-Image",
"prompt": "一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感",
"size": "2720x1536",
"n": 2,
"response_format": "url"
}
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: 'MiniMax-H3-Image',
prompt: '一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感',
size: '2720x1536',
n: 2,
response_format: 'url'
})
};
fetch('https://api.minimax.cn/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.minimax.cn/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' => 'MiniMax-H3-Image',
'prompt' => '一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感',
'size' => '2720x1536',
'n' => 2,
'response_format' => 'url'
]),
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.minimax.cn/v1/images/generations"
payload := strings.NewReader("{\n \"model\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\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.minimax.cn/v1/images/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.minimax.cn/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\": \"MiniMax-H3-Image\",\n \"prompt\": \"一只橘猫趴在窗台上晒太阳,午后暖光,胶片质感\",\n \"size\": \"2720x1536\",\n \"n\": 2,\n \"response_format\": \"url\"\n}"
response = http.request(request)
puts response.read_body{
"created": 1792308678,
"data": [
{
"url": "https://example.com/h3-image/output-0.jpg",
"size": "2720x1536",
"revised_prompt": "午后的暖光透过木质窗框洒在窗台上,一只橘猫侧身趴着晒太阳,眯着眼睛,毛发被阳光勾出金色轮廓,背景是虚化的室内绿植,胶片颗粒质感,柔和的暖色调"
},
{
"error": {
"code": "1027",
"message": "output image failed content safety check"
}
}
],
"output_format": "jpeg",
"usage": {
"generated_images": 1,
"total_tokens": 7254,
"input_tokens": 3174,
"output_tokens": 4080,
"input_tokens_details": {
"text_tokens": 3174,
"image_tokens": 0
},
"output_tokens_details": {
"image_tokens": 4080
}
},
"request_id": "021792308678142a2c883cf675b9804d"
}MiniMax-H3-Image、MiniMax-H3-Image-Highspeed,两者参数与限制相同。
max_retries=0,关闭默认的自动重试。授权
请求体
模型名称。可选值:MiniMax-H3-Image、MiniMax-H3-Image-Highspeed,两者参数与限制相同
MiniMax-H3-Image, MiniMax-H3-Image-Highspeed 图片的文本描述,最长 32000 个字符(按 Unicode 字符计,不含首尾空白),为空或只含空白时返回 400。关闭 Prompt 增强(disable_prompt_enhanced 为 true)时,模型只读取约前 4096 个 token,超出部分不生效。
32000是否关闭 Prompt 增强,默认 false(开启增强),增强结果见 data[].revised_prompt。
设为 true 时直接使用原始 prompt,输出比例必须由请求给出,二选一:
size为宽x高size不传或为auto,aspect_ratio为X:Y(area可不传,默认4K)
size 不是 宽x高、且 aspect_ratio 不传或为 auto 时返回 400。
生成图片数量,取值范围 [1, 10],默认 1。
1 <= x <= 10输出宽高比,默认 auto。
size为宽x高时不能传入(传auto也不行),否则返回 400size不传或为auto、且disable_prompt_enhanced为true时必须传X:Y,不传或传auto返回 400
取值:
auto:由 Prompt 增强根据内容决定X:Y:X、Y 为 1 ~ 300 的整数,宽高比在 1:3 ~ 3:1 之间(含边界),如16:9、3:4、21:9、3:1
"16:9"
输出面积档位,默认 4K。只能在 size 不传或为 auto 时传入,size 为 宽x高 时传入返回 400。
1K、2K、4K 的目标面积分别为 1024 × 1024、2048 × 2048、4096 × 4096 像素,宽高由服务端按宽高比计算,如 2K 搭配 16:9 输出 2720 × 1536。每张的实际宽高见 data[].size。
1K, 2K, 4K 输出图片格式,默认 jpeg。可用值:png、jpeg、jpg、webp。jpg 与 jpeg 等价,响应中的 output_format 返回 jpeg。
png, jpeg, jpg, webp 返回形式,默认 url。
url:图片链接,有效期 24 小时,请在有效期内下载并自行保存b64_json:Base64 编码的图片数据,不支持流式
b64_json 的总输出面积(n × 宽 × 高)上限如下,超出返回 400(size 为 auto 时每张按 area 对应的面积计,如 4K 按 4096 × 4096):
output_format | 总面积上限 | 参考 |
|---|---|---|
png | 20,000,000 px | 1 张任意尺寸 |
jpeg / webp | 80,000,000 px | 最多 4 张 4K,或 10 张 2K |
url, b64_json 是否流式输出,默认 false。开启后响应为 text/event-stream(SSE),仅支持 response_format 为 url:
- 每张图片处理完推送一个事件:成功为
image_generation.partial_succeeded,失败为image_generation.partial_failed。事件按完成先后推送,用image_index对应张序 - 全部结束后推送
image_generation.completed,包含usage和request_id - 响应头返回后,全部图片失败或提交生成前失败时推送
error事件 - 响应头返回前的错误(参数错误、鉴权失败、限流、余额不足等)仍以普通 HTTP 错误返回,与非流式相同;请先检查 HTTP 状态码,再按 SSE 解析
事件结构见流式响应事件。
压缩质量,取值范围 [0, 100],默认 95,数值越大画质越高、文件越大。仅对 jpeg / webp 生效,输出 png 时忽略;超出取值范围返回 400。
0 <= x <= 100是否在图片上添加可见的 AIGC 标识水印,默认 false。AIGC 隐式标识(写在图片文件的元数据中)按合规要求写入,不受该参数控制。
响应
stream 为 false(默认)时返回 application/json。stream 为 true 时返回 text/event-stream(SSE),每个事件的 data 为 JSON,结构见 text/event-stream 的响应定义,事件说明与完整示例见流式响应事件。
响应生成时间,Unix 时间戳(秒)。
图片列表,始终为 n 项,按张序排列(与流式事件的 image_index 一致)。成功的项返回 url(或 b64_json)、size 和 revised_prompt;失败的项(包括未通过内容安全检查的)只返回 error。
只要有 1 张成功,HTTP 状态码就是 200,请逐项检查 data[].error;全部失败时返回 402、422 或 500 的错误响应。只对成功的图片计费。
Show child attributes
Show child attributes
生成图片的格式。
png, jpeg, webp 本次请求的 token 用量,只统计成功的图片,按此计费。total_tokens 为 input_tokens 与 output_tokens 之和。
Show child attributes
Show child attributes
请求 ID(即 Trace ID),反馈问题时请提供。
此页面对您有帮助吗?