Passer au contenu principal
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>"
}

Options de dimensionnement

Les modèles d’image utilisent des paramètres de dimensionnement spécifiques au modèle :
  • Les modèles basés sur les pixels acceptent width et height, par exemple venice-sd35 et qwen-image.
  • Les modèles basés sur le ratio d’aspect acceptent aspect_ratio, par exemple qwen-image-2.
  • Les modèles à niveaux de résolution acceptent à la fois aspect_ratio et resolution.
Par exemple, gpt-image-2, nano-banana-2 et nano-banana-pro prennent en charge les valeurs resolution de 1K, 2K et 4K :
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
Le même schéma de dimensionnement par niveau de résolution s’applique aussi aux modèles Nano Banana :
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
Pour les modèles qui acceptent le ratio d’aspect mais n’exposent pas de niveaux de résolution, envoyez aspect_ratio sans resolution :
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
Pour les modèles qui utilisent des dimensions de pixel directes, envoyez plutôt width et height :
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
Vérifiez Modèles d’image ou l’endpoint Models pour les options de dimensionnement prises en charge par chaque modèle avant de mélanger des champs de dimensionnement entre les modèles.

Niveaux de qualité

Certains modèles acceptent un paramètre quality optionnel (low, medium, high) qui arbitre entre fidélité visuelle et coût. Actuellement pris en charge par gpt-image-2 ; les autres modèles ignorent ce paramètre.
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
Lorsque vous omettez quality, le modèle utilise son niveau par défaut (high pour gpt-image-2). Le prix dépend de la combinaison de resolution et quality — les prix par niveau pour gpt-image-2 (1K/2K/4K × low/medium/high) sont exposés sous model_spec.pricing.quality dans l’endpoint Models et listés dans l’aperçu de la tarification.
La tarification consciente de la qualité est la valeur par défaut pour tous les appelants de l’API et du SDK — aucun en-tête d’opt-in requis. Les requêtes qui omettent quality sont facturées au niveau par défaut du modèle (high pour gpt-image-2).

Collection Postman

Pour des exemples supplémentaires, veuillez consulter cette collection Postman.

Autorisations

Authorization
string
header
requis

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

En-têtes

Accept-Encoding
string

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

Exemple:

"gzip, br"

Corps

application/json
model
string
requis

The model to use for image generation.

Exemple:

"grok-imagine-image"

prompt
string
requis

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

"A beautiful sunset over a mountain range"

cfg_scale
number

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

Plage requise: 0 < x <= 20
Exemple:

7.5

embed_exif_metadata
boolean
défaut:false

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

Exemple:

false

format
enum<string>
défaut:webp

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

Options disponibles:
jpeg,
png,
webp
Exemple:

"webp"

height
integer
défaut:1024

Height of the generated image.

Plage requise: 0 < x <= 1280
Exemple:

1024

hide_watermark
boolean
défaut:false

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

Exemple:

false

inpaint
any | null
obsolète

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.

Plage requise: 0 <= x <= 100
Exemple:

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

"Clouds, Rain, Snow"

return_binary
boolean
défaut:false

Whether to return binary image data instead of base64.

Exemple:

false

variants
integer

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

Plage requise: 1 <= x <= 4
Exemple:

3

safe_mode
boolean
défaut:true

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

Exemple:

false

seed
integer
défaut:0

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

Plage requise: -999999999 <= x <= 999999999
Exemple:

123456789

steps
integer
défaut:8

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

Exemple:

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.

Exemple:

"3D Model"

aspect_ratio
string

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

Exemple:

"1:1"

resolution
string

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

Exemple:

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

Options disponibles:
low,
medium,
high
Exemple:

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

Exemple:

false

width
integer
défaut:1024

Width of the generated image.

Plage requise: 0 < x <= 1280
Exemple:

1024

Réponse

Successfully generated image

id
string
requis

The ID of the request.

Exemple:

"generate-image-1234567890"

images
string[]
requis

Base64 encoded image data.

timing
object
requis
request
any | null

The original request data sent to the API.