Zum Hauptinhalt springen
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>"
}

Größenoptionen

Bildmodelle verwenden modellspezifische Parameter für die Bildgröße:
  • Pixelbasierte Modelle akzeptieren width und height, zum Beispiel venice-sd35 und qwen-image.
  • Seitenverhältnis-Modelle akzeptieren aspect_ratio, zum Beispiel qwen-image-2.
  • Auflösungsstufen-Modelle akzeptieren sowohl aspect_ratio als auch resolution.
Zum Beispiel unterstützen gpt-image-2, nano-banana-2 und nano-banana-pro resolution-Werte von 1K, 2K und 4K:
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
Dasselbe Muster mit Auflösungsstufen gilt auch für die Nano-Banana-Modelle:
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
Für Modelle, die ein Seitenverhältnis akzeptieren, aber keine Auflösungsstufen anbieten, senden Sie aspect_ratio ohne resolution:
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
Für Modelle, die direkte Pixeldimensionen verwenden, senden Sie stattdessen width und height:
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
Prüfen Sie Image Models oder den Models-Endpoint für die unterstützten Größenoptionen jedes Modells, bevor Sie Größenfelder zwischen Modellen mischen.

Qualitätsstufen

Einige Modelle akzeptieren einen optionalen Parameter quality (low, medium, high), der visuelle Qualität gegen Kosten abwägt. Derzeit von gpt-image-2 unterstützt; andere Modelle ignorieren den Parameter.
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
Wenn Sie quality weglassen, verwendet das Modell seine Standardstufe (high für gpt-image-2). Die Preise hängen von der Kombination aus resolution und quality ab — die Preise pro Stufe für gpt-image-2 (1K/2K/4K × low/medium/high) sind unter model_spec.pricing.quality im Models-Endpoint sichtbar und in der Preisübersicht aufgeführt.
Qualitätsabhängige Preise sind der Standard für alle API- und SDK-Aufrufer — kein Opt-in-Header erforderlich. Anfragen, bei denen quality weggelassen wird, werden mit der Standardstufe des Modells abgerechnet (high für gpt-image-2).

Postman-Collection

Weitere Beispiele finden Sie in dieser Postman-Collection.

Autorisierungen

Authorization
string
header
erforderlich

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

Header

Accept-Encoding
string

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

Beispiel:

"gzip, br"

Body

application/json
model
string
erforderlich

The model to use for image generation.

Beispiel:

"grok-imagine-image"

prompt
string
erforderlich

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
Beispiel:

"A beautiful sunset over a mountain range"

cfg_scale
number

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

Erforderlicher Bereich: 0 < x <= 20
Beispiel:

7.5

embed_exif_metadata
boolean
Standard:false

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

Beispiel:

false

format
enum<string>
Standard:webp

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

Verfügbare Optionen:
jpeg,
png,
webp
Beispiel:

"webp"

height
integer
Standard:1024

Height of the generated image.

Erforderlicher Bereich: 0 < x <= 1280
Beispiel:

1024

hide_watermark
boolean
Standard:false

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

Beispiel:

false

inpaint
any | null
veraltet

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.

Erforderlicher Bereich: 0 <= x <= 100
Beispiel:

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
Beispiel:

"Clouds, Rain, Snow"

return_binary
boolean
Standard:false

Whether to return binary image data instead of base64.

Beispiel:

false

variants
integer

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

Erforderlicher Bereich: 1 <= x <= 4
Beispiel:

3

safe_mode
boolean
Standard:true

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

Beispiel:

false

seed
integer
Standard:0

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

Erforderlicher Bereich: -999999999 <= x <= 999999999
Beispiel:

123456789

steps
integer
Standard:8

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

Beispiel:

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.

Beispiel:

"3D Model"

aspect_ratio
string

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

Beispiel:

"1:1"

resolution
string

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

Beispiel:

"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.

Verfügbare Optionen:
low,
medium,
high
Beispiel:

"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.

Beispiel:

false

width
integer
Standard:1024

Width of the generated image.

Erforderlicher Bereich: 0 < x <= 1280
Beispiel:

1024

Antwort

Successfully generated image

id
string
erforderlich

The ID of the request.

Beispiel:

"generate-image-1234567890"

images
string[]
erforderlich

Base64 encoded image data.

timing
object
erforderlich
request
any | null

The original request data sent to the API.