Vai al contenuto principale
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>"
}

Opzioni di dimensionamento

I modelli di immagine usano parametri di dimensionamento specifici per modello:
  • I modelli basati su pixel accettano width e height, ad esempio venice-sd35 e qwen-image.
  • I modelli basati su aspect ratio accettano aspect_ratio, ad esempio qwen-image-2.
  • I modelli a livelli di risoluzione accettano sia aspect_ratio sia resolution.
Ad esempio, gpt-image-2, nano-banana-2 e nano-banana-pro supportano i valori di resolution 1K, 2K e 4K:
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
Lo stesso pattern di dimensionamento a livelli di risoluzione si applica anche ai modelli Nano Banana:
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
Per i modelli che accettano aspect ratio ma non espongono livelli di risoluzione, invia aspect_ratio senza resolution:
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
Per i modelli che usano dimensioni in pixel dirette, invia invece width e height:
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
Controlla Modelli immagine o l’endpoint Models per le opzioni di dimensionamento supportate da ciascun modello prima di mischiare campi di dimensionamento tra modelli diversi.

Livelli di qualità

Alcuni modelli accettano un parametro opzionale quality (low, medium, high) che bilancia fedeltà visiva e costo. Attualmente supportato da gpt-image-2; gli altri modelli ignorano il parametro.
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
Quando ometti quality, il modello usa il proprio livello predefinito (high per gpt-image-2). Il prezzo dipende dalla combinazione di resolution e quality — i prezzi per livello per gpt-image-2 (1K/2K/4K × low/medium/high) sono esposti sotto model_spec.pricing.quality nell’endpoint Models ed elencati nella panoramica dei prezzi.
I prezzi basati sulla qualità sono l’impostazione predefinita per tutti i chiamanti API e SDK — non è richiesto alcun header di opt-in. Le richieste che omettono quality vengono fatturate al livello predefinito del modello (high per gpt-image-2).

Postman Collection

Per ulteriori esempi, consulta questa Postman Collection.

Autorizzazioni

Authorization
string
header
obbligatorio

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

Intestazioni

Accept-Encoding
string

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

Esempio:

"gzip, br"

Corpo

application/json
model
string
obbligatorio

The model to use for image generation.

Esempio:

"grok-imagine-image"

prompt
string
obbligatorio

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

"A beautiful sunset over a mountain range"

cfg_scale
number

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

Intervallo richiesto: 0 < x <= 20
Esempio:

7.5

embed_exif_metadata
boolean
predefinito:false

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

Esempio:

false

format
enum<string>
predefinito:webp

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

Opzioni disponibili:
jpeg,
png,
webp
Esempio:

"webp"

height
integer
predefinito:1024

Height of the generated image.

Intervallo richiesto: 0 < x <= 1280
Esempio:

1024

hide_watermark
boolean
predefinito:false

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

Esempio:

false

inpaint
any | null
deprecato

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.

Intervallo richiesto: 0 <= x <= 100
Esempio:

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

"Clouds, Rain, Snow"

return_binary
boolean
predefinito:false

Whether to return binary image data instead of base64.

Esempio:

false

variants
integer

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

Intervallo richiesto: 1 <= x <= 4
Esempio:

3

safe_mode
boolean
predefinito:true

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

Esempio:

false

seed
integer
predefinito:0

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

Intervallo richiesto: -999999999 <= x <= 999999999
Esempio:

123456789

steps
integer
predefinito:8

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

Esempio:

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.

Esempio:

"3D Model"

aspect_ratio
string

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

Esempio:

"1:1"

resolution
string

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

Esempio:

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

Opzioni disponibili:
low,
medium,
high
Esempio:

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

Esempio:

false

width
integer
predefinito:1024

Width of the generated image.

Intervallo richiesto: 0 < x <= 1280
Esempio:

1024

Risposta

Successfully generated image

id
string
obbligatorio

The ID of the request.

Esempio:

"generate-image-1234567890"

images
string[]
obbligatorio

Base64 encoded image data.

timing
object
obbligatorio
request
any | null

The original request data sent to the API.