跳转到主要内容
POST
/
v1
/
image_generation
Image Generation
curl --request POST \
  --url https://api.minimaxi.com/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, 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
}'
{
  "id": "03ff3cd0820949eb8a410056b5f21d38",
  "data": {
    "image_urls": [
      "XXX",
      "XXX",
      "XXX"
    ]
  },
  "metadata": {
    "failed_count": "0",
    "success_count": "3"
  },
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

Authorizations

Authorization
string
header
required

HTTP: Bearer Auth

  • Security Scheme Type: http
  • HTTP Authorization Scheme: Bearer API_key,用于验证账户信息,可在 账户管理>接口密钥 中查看。

Headers

Content-Type
enum<string>
default:application/json
required

请求体的媒介类型,请设置为 application/json 确保请求数据的格式为 JSON.

Available options:
application/json

Body

application/json
model
enum<string>
required

模型名称。可选值:image-01image-01-live

Available options:
image-01
prompt
string
required

图像的文本描述,最长 1500 字符

style
object

画风设置,仅当 modelimage-01-live 时生效

aspect_ratio
enum<string>

图像宽高比,默认为 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)
Available options:
1:1,
16:9,
4:3,
3:2,
2:3,
3:4,
9:16,
21:9
width
integer

生成图片的宽度(像素)。仅当 model 为 image-01 时生效。注意:widthheight 需同时设置,取值范围[512, 2048],且必须是 8 的倍数。若与 aspect_ratio 同时设置,则优先使用 aspect_ratio

height
integer

生成图片的高度(像素)。仅当 model 为 image-01 时生效。注意:widthheight 需同时设置,取值范围[512, 2048],且必须是 8 的倍数。若与 aspect_ratio 同时设置,则优先使用 aspect_ratio

response_format
enum<string>
default:url

返回图片的形式,默认为 url。可选值:url, base64。 ⚠️ 注意:url 的有效期为 24 小时

Available options:
url,
base64
seed
integer

随机种子。使用相同的 seed 和参数,可以生成内容相近的图片,用于复现结果。如未提供,算法会对 n 张图单独生成随机种子

n
integer
default:1

单次请求生成的图片数量,取值范围[1, 9],默认为 1

Required range: 1 <= x <= 9
prompt_optimizer
boolean
default:false

是否开启 prompt 自动优化,默认为 false.

aigc_watermark
boolean

是否在生成的图片中添加水印,默认为 false

Response

200 - application/json
data
object
metadata
object

因内容安全检查失败而未返回的图片数量

id
string

生成任务的 ID,用于后续查询任务状态

base_resp
object
I