跳转到主要内容
POST
/
image
/
generate
/api/v1/image/generate
curl --request POST \
  --url https://api.venice.ai/api/v1/image/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "grok-imagine-image",
  "prompt": "A beautiful sunset over a mountain range",
  "cfg_scale": 7.5,
  "embed_exif_metadata": false,
  "format": "webp",
  "height": 1024,
  "hide_watermark": false,
  "inpaint": "<unknown>",
  "lora_strength": 50,
  "negative_prompt": "Clouds, Rain, Snow",
  "return_binary": false,
  "variants": 3,
  "safe_mode": false,
  "seed": 123456789,
  "steps": 8,
  "style_preset": "3D Model",
  "aspect_ratio": "1:1",
  "resolution": "1K",
  "quality": "high",
  "enable_web_search": false,
  "width": 1024
}
'
{
  "id": "generate-image-1234567890",
  "images": [
    "<string>"
  ],
  "timing": {
    "inferenceDuration": 123,
    "inferencePreprocessingTime": 123,
    "inferenceQueueTime": 123,
    "total": 123
  },
  "request": "<unknown>"
}

尺寸选项

图像模型使用模型专属的尺寸参数:
  • 基于像素的模型接受 widthheight,例如 venice-sd35qwen-image
  • 基于宽高比的模型接受 aspect_ratio,例如 qwen-image-2
  • 基于分辨率等级的模型同时接受 aspect_ratioresolution
例如,gpt-image-2nano-banana-2nano-banana-pro 支持 resolution 取值 1K2K4K
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
相同的分辨率分级尺寸模式也适用于 Nano Banana 模型:
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
对于接受宽高比但不公开分辨率等级的模型,请发送 aspect_ratio 而不带 resolution
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
对于使用直接像素尺寸的模型,请改为发送 widthheight
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
在跨模型混用尺寸字段之前,请查看图像模型Models 端点了解每个模型支持的尺寸选项。

质量等级

部分模型接受可选的 quality 参数(lowmediumhigh),用于在视觉保真度和成本之间取得平衡。当前由 gpt-image-2 支持;其他模型会忽略该参数。
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
当您省略 quality 时,模型将使用其默认等级(gpt-image-2high)。价格取决于 resolutionquality 的组合 —— gpt-image-2 的各等级价格(1K/2K/4K × low/medium/high)在 Models 端点model_spec.pricing.quality 下公开,也列于定价概览中。
质量感知定价是所有 API 和 SDK 调用方的默认行为 —— 无需显式启用的请求头。省略 quality 的请求按模型的默认等级(gpt-image-2high)计费。

Postman 集合

如需更多示例,请参阅此 Postman 集合

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求头

Accept-Encoding
string

Supported compression encodings (gzip, br). Only applied when return_binary is false.

示例:

"gzip, br"

请求体

application/json
model
string
必填

The model to use for image generation.

示例:

"grok-imagine-image"

prompt
string
必填

The description for the image. Character limit is model specific and is listed in the promptCharacterLimit setting in the model list endpoint.

Required string length: 1 - 7500
示例:

"A beautiful sunset over a mountain range"

cfg_scale
number

CFG scale parameter. Higher values lead to more adherence to the prompt.

必填范围: 0 < x <= 20
示例:

7.5

embed_exif_metadata
boolean
默认值:false

Embed prompt generation information into the image's EXIF metadata.

示例:

false

format
enum<string>
默认值:webp

The image format to return. WebP are smaller and optimized for web use. PNG are higher quality but larger in file size.

可用选项:
jpeg,
png,
webp
示例:

"webp"

height
integer
默认值:1024

Height of the generated image.

必填范围: 0 < x <= 1280
示例:

1024

hide_watermark
boolean
默认值:false

Whether to hide the Venice watermark. Venice may ignore this parameter for certain generated content.

示例:

false

inpaint
any | null
已弃用

This feature is deprecated and was disabled on May 19th, 2025. A revised in-painting API will be launched in the near future.

lora_strength
integer

Lora strength for the model. Only applies if the model uses additional Loras.

必填范围: 0 <= x <= 100
示例:

50

negative_prompt
string

A description of what should not be in the image. Character limit is model specific and is listed in the promptCharacterLimit constraint in the model list endpoint.

Maximum string length: 7500
示例:

"Clouds, Rain, Snow"

return_binary
boolean
默认值:false

Whether to return binary image data instead of base64.

示例:

false

variants
integer

Number of images to generate (1–4). Only supported when return_binary is false.

必填范围: 1 <= x <= 4
示例:

3

safe_mode
boolean
默认值:true

Whether to use safe mode. If enabled, this will blur images that are classified as having adult content.

示例:

false

seed
integer
默认值:0

Random seed for generation. If not provided, a random seed will be used.

必填范围: -999999999 <= x <= 999999999
示例:

123456789

steps
integer
默认值:8

Number of inference steps. This model does not support steps - this field is ignored.

示例:

8

style_preset
string

An image style to apply to the image. Visit https://docs.venice.ai/api-reference/endpoint/image/styles for more details.

示例:

"3D Model"

aspect_ratio
string

Aspect ratio (utilized by certain image models including Nano Banana). Examples: "1:1", "16:9".

示例:

"1:1"

resolution
string

Resolution (utilized by certain image models including Nano Banana). Examples: "1K", "2K", "4K".

示例:

"1K"

quality
enum<string>

Output quality for supported models (e.g. GPT Image 2 / GPT Image 2 Edit). Higher values can increase the final request charge. See the model list for supported options.

可用选项:
low,
medium,
high
示例:

"high"

Enable web search for the image generation task. This will allow the model to use the latest information from the web to generate the image. Only supported by certain models. If web search is used, additional credits are getting charged.

示例:

false

width
integer
默认值:1024

Width of the generated image.

必填范围: 0 < x <= 1280
示例:

1024

响应

Successfully generated image

id
string
必填

The ID of the request.

示例:

"generate-image-1234567890"

images
string[]
必填

Base64 encoded image data.

timing
object
必填
request
any | null

The original request data sent to the API.