> ## Documentation Index
> Fetch the complete documentation index at: https://docs.venice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# Image Generation

> Generate images from text prompts with Venice's /image/generate endpoint or the OpenAI-compatible API, with style presets and base64 output.

Image generation on Venice is synchronous. Send a prompt to `/image/generate` and receive your image in the same response, either as base64 inside JSON or as raw binary when `return_binary` is `true`.

## Endpoints

| Endpoint | Purpose | When to use |
| - | - | - |
| `POST /image/generate` | Native Venice image generation API | Use this for full feature support |
| `GET /image/styles` | List available style presets | Use this before sending `style_preset` |
| `POST /images/generations` | OpenAI-compatible image generation API | Use this when migrating existing OpenAI image clients |

## Step 1: Send a generation request

Sizing is model-specific. Some models accept explicit `width` and `height`; some expose `aspect_ratio`; and resolution-tier models expose `aspect_ratio` plus `resolution` values such as `1K`, `2K`, or `4K`.

`width` and `height` accept up to `4096` pixels each. How Venice uses them depends on the model:

* Models that render an exact canvas, such as `venice-sd35`, require each side to be at most `1280` before any model upscale.
* Models that list aspect ratios treat `width` and `height` as a size hint. Venice picks the nearest supported `aspect_ratio` and a resolution tier from the long edge: above `1536` selects `2K` and above `3072` selects `4K`. If the model doesn't offer that tier, Venice uses the highest offered tier at or below it, otherwise the model default.
* An explicit `aspect_ratio` or `resolution` in the same request overrides only its own value. For example, `width: 3840, height: 2160` with `aspect_ratio: "1:1"` still selects `4K` but renders square.

> [!WARNING]
>
> `qwen-image`, `qwen-image-3`, `qwen-image-3-pro`, `qwen-image-2-1-turbo`, and `qwen-image-2-1-pro` no longer accept `width` or `height`. Sending either returns `400` with *"`width` and `height` are no longer supported for this model. Use `aspect_ratio` instead."* Check `model_spec.constraints` from `GET /models?type=image` before choosing sizing fields.

**Pixel-based sizing example:**

```http theme={"system"}
POST https://api.venice.ai/api/v1/image/generate
Authorization: Bearer $VENICE_API_KEY
Content-Type: application/json

{
  "model": "venice-sd35",
  "prompt": "A cinematic photo of a gondola passing through a narrow Venice canal at blue hour, warm window lights reflecting on the water",
  "negative_prompt": "blurry, low quality, distorted anatomy, text, watermark",
  "width": 1024,
  "height": 1024,
  "format": "webp"
}
```

**Aspect-ratio sizing example:**

```http theme={"system"}
POST https://api.venice.ai/api/v1/image/generate
Authorization: Bearer $VENICE_API_KEY
Content-Type: application/json

{
  "model": "qwen-image-2",
  "prompt": "A cinematic photo of a gondola passing through a narrow Venice canal at blue hour",
  "aspect_ratio": "16:9",
  "format": "webp"
}
```

**Resolution-tier sizing example:**

```http theme={"system"}
POST https://api.venice.ai/api/v1/image/generate
Authorization: Bearer $VENICE_API_KEY
Content-Type: application/json

{
  "model": "gpt-image-2",
  "prompt": "A cinematic wide shot of a gondola passing through a narrow Venice canal at blue hour",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
```

The same pattern applies to other resolution-tier models:

```json theme={"system"}
{
  "model": "nano-banana-pro",
  "prompt": "A serene canal in Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
```

Use [Image Models](https://docs.venice.ai/models/image.md) or the [Models API](https://docs.venice.ai/api-reference/endpoint/models/list.md) to confirm which sizing fields each model accepts.

**Response (200):**

```json theme={"system"}
{
  "id": "generate-image-1234567890",
  "images": [
    "UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoQABAAPm..."
  ],
  "timing": {
    "inferenceDuration": 1840,
    "inferencePreprocessingTime": 22,
    "inferenceQueueTime": 31,
    "total": 1893
  }
}
```

The `images` array contains base64-encoded image data. Decode the first item to save or display it. `timing.total` is the full request duration in milliseconds.

## Step 2: Decode and save the image

```python Python theme={"system"}
import base64
import os
import requests

response = requests.post(
    "https://api.venice.ai/api/v1/image/generate",
    headers={
        "Authorization": f"Bearer {os.environ['VENICE_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "venice-sd35",
        "prompt": "A cinematic photo of a gondola passing through a narrow Venice canal at blue hour, warm window lights reflecting on the water",
        "width": 1024,
        "height": 1024,
        "format": "webp",
    },
)

data = response.json()
image_bytes = base64.b64decode(data["images"][0])

with open("output.webp", "wb") as f:
    f.write(image_bytes)

print(f"Saved image from request {data['id']}")
```

```javascript Node.js theme={"system"}
import fs from "fs";

const response = await fetch("https://api.venice.ai/api/v1/image/generate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VENICE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "venice-sd35",
    prompt: "A cinematic photo of a gondola passing through a narrow Venice canal at blue hour, warm window lights reflecting on the water",
    width: 1024,
    height: 1024,
    format: "webp",
  }),
});

const data = await response.json();
const imageBuffer = Buffer.from(data.images[0], "base64");
fs.writeFileSync("output.webp", imageBuffer);

console.log(`Saved image from request ${data.id}`);
```

## Step 3: Return binary instead of JSON (optional)

If you want the response body to be the image file itself, set `return_binary: true`. This is useful when you want to stream or save the image directly without base64 decoding.

```bash theme={"system"}
curl https://api.venice.ai/api/v1/image/generate \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -o output.png \
  -d '{
    "model": "qwen-image-2",
    "prompt": "Minimalist poster of a moonlit Venetian bridge in deep blue tones",
    "format": "png",
    "return_binary": true
  }'
```

When `return_binary` is `true`, the response body is raw `image/jpeg`, `image/png`, or `image/webp` data based on the `format` you requested.

> [!NOTE]
>
> `variants` is only supported when `return_binary` is `false`.

***

## Step 4: List available image styles (optional)

If you want to use `style_preset`, first fetch the available styles from `/image/styles`:

```bash theme={"system"}
curl https://api.venice.ai/api/v1/image/styles
```

This endpoint is public and does not require an API key.

**Response (200):**

```json theme={"system"}
{
  "object": "list",
  "data": [
    "3D Model",
    "Analog Film",
    "Anime",
    "Cinematic",
    "Digital Art"
  ]
}
```

The style names are inside `data`, not at the top level — read `response.data` rather than iterating the response object directly.

Then pass one of those values into your generation request:

```json theme={"system"}
{
  "model": "qwen-image-2",
  "prompt": "A futuristic Venice skyline at sunrise",
  "style_preset": "Cinematic"
}
```

Use the styles endpoint when you want exact preset names instead of guessing them.

***

## Request Parameters

| Parameter | Type | Required | Default | Description |
| - | - | - | - | - |
| `model` | string | Yes | - | Model ID to use for generation |
| `prompt` | string | Yes | - | What to generate |
| `negative_prompt` | string | No | - | What to avoid in the image |
| `width` | integer | No | `1024` | Output width in pixels, up to `4096`. Exact-canvas models such as `venice-sd35` cap each side at `1280`. On aspect-ratio models, it selects the nearest `aspect_ratio` and a resolution tier (see [Step 1](#step-1-send-a-generation-request)). Rejected by the Qwen Image family (see the note below) |
| `height` | integer | No | `1024` | Output height in pixels, up to `4096`. Exact-canvas models such as `venice-sd35` cap each side at `1280`. On aspect-ratio models, it selects the nearest `aspect_ratio` and a resolution tier (see [Step 1](#step-1-send-a-generation-request)). Rejected by the Qwen Image family (see the note below) |
| `format` | string | No | `webp` | Output format: `jpeg`, `png`, or `webp` |
| `variants` | integer | No | `1` | Number of images to generate (`1`-`4`), only when `return_binary` is `false`. An explicit provider content-policy rejection can omit individual variants; see [Partial variant results](#partial-variant-results) |
| `return_binary` | boolean | No | `false` | Return raw image bytes instead of base64 JSON |
| `safe_mode` | boolean | No | `true` | Blur adult content when enabled |
| `seed` | integer | No | random | Reuse the same seed for more consistent iterations |
| `cfg_scale` | number | No | model-dependent | Higher values push the model to follow the prompt more closely |
| `lora_strength` | integer | No | - | Strength (`0`-`100`) of the additional LoRAs a model uses. See [LoRA strength](#lora-strength) |
| `style_preset` | string | No | - | Apply a preset style from [Image Styles](https://docs.venice.ai/api-reference/endpoint/image/styles.md) |
| `style_references` | array | No | - | Style reference images that guide the output's aesthetic. Each entry is `{ "image": <url or base64>, "strength": <0.1-1> }`. Supported models only; see [Style references](#style-references) |
| `aspect_ratio` | string | Conditional | - | Used by models that support ratio-based sizing, such as `qwen-image-2`, `gpt-image-2`, `nano-banana-2`, and `nano-banana-pro` |
| `resolution` | string | Conditional | - | Used by models that support resolution tiers such as `1K`, `2K`, or `4K` |
| `enable_web_search` | boolean | Conditional | `false` | Allows supported models to use current web information; adds extra cost |
| `transparent_background` | boolean | No | `false` | Return a PNG or WebP with a real alpha channel. Requires a model with `supportsTransparentBackground: true` and `format` `png` or `webp`. See [Transparent Background Images](https://docs.venice.ai/guides/media/transparent-backgrounds.md) |

Validation is model-specific. Check [Image Models](https://docs.venice.ai/models/image.md) and the [Models API](https://docs.venice.ai/api-reference/endpoint/models/list.md) before relying on a parameter across multiple models.

***

## Model-specific options

### High-resolution generation

Some image models support `aspect_ratio` without a selectable `resolution` tier. For example, `qwen-image-2` accepts aspect ratio and maps it to model-specific output dimensions:

```json theme={"system"}
{
  "model": "qwen-image-2",
  "prompt": "Editorial product photo of a luxury watch on black marble, dramatic studio lighting",
  "aspect_ratio": "16:9"
}
```

Other image models support `aspect_ratio` plus a `resolution` tier. For example, `gpt-image-2`, `nano-banana-2`, and `nano-banana-pro` support `1K`, `2K`, and `4K`:

```json theme={"system"}
{
  "model": "gpt-image-2",
  "prompt": "Editorial product photo of a luxury watch on black marble, dramatic studio lighting",
  "aspect_ratio": "16:9",
  "resolution": "4K"
}
```

```json theme={"system"}
{
  "model": "nano-banana-2",
  "prompt": "Editorial product photo of a luxury watch on black marble, dramatic studio lighting",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
```

Use [Image Models](https://docs.venice.ai/models/image.md) to see which models support higher resolutions and how they are priced.

### LoRA strength

Some image models apply additional LoRAs. `lora_strength` (integer, `0` to `100`) sets how strongly they are applied, and it only affects models that use them.

The API does not accept custom LoRA files, and no endpoint lists the LoRAs a model uses. `lora_strength` is the only LoRA control.

### Adult content and safe mode

`safe_mode` controls whether adult content in generation output is blurred. It defaults to `true`, so images classified as adult come back blurred unless you send `safe_mode: false`:

```json theme={"system"}
{
  "model": "lustify-v8",
  "prompt": "…",
  "safe_mode": false
}
```

Unblurred adult (NSFW) images are available to every API user. You don't need a Pro subscription, and the mature filter setting in the Venice app does not affect image requests made through the API.

Some image models are specifically designed for adult / uncensored generation and pair well with `safe_mode: false`. Examples include `lustify-sdxl`, `lustify-v7`, and `lustify-v8`. See [Image Models](https://docs.venice.ai/models/image.md) for the current list and per-model costs.

For editing existing images, the default edit model is `firered-image-edit`. Content policies vary by edit model; if you need uncensored editing, use `qwen-edit-uncensored` via [Image Editing](https://docs.venice.ai/guides/media/image-editing.md).

When `safe_mode` is enabled and the model returns blurred or moderated output, inspect the `x-venice-is-blurred` and `x-venice-is-content-violation` response headers if you need to detect that programmatically.

> [!NOTE]
>
> Using a third-party app? Adult images stay blurred unless the app sends `safe_mode: false`, or `moderation: "low"` on the OpenAI-compatible endpoint (see below).

### Style presets

If the selected model supports it, `style_preset` lets you steer the output without rewriting your whole prompt. You can fetch valid preset names from [Image Styles](https://docs.venice.ai/api-reference/endpoint/image/styles.md):

```json theme={"system"}
{
  "model": "qwen-image-2",
  "prompt": "A futuristic Venice skyline at sunrise",
  "style_preset": "3D Model"
}
```

See [Image Styles](https://docs.venice.ai/api-reference/endpoint/image/styles.md) for the current style list.

### Style references

`style_references` goes a step further than `style_preset`: instead of a named preset, it conditions generation on one or more reference images. Each entry has an `image` and an optional `strength`:

```json theme={"system"}
{
  "model": "krea-v2-large",
  "prompt": "A quiet Venetian courtyard at golden hour",
  "style_references": [
    {
      "image": "https://example.com/reference-painting.png",
      "strength": 0.5
    }
  ]
}
```

| Field | Type | Required | Description |
| - | - | - | - |
| `image` | string | Yes | Reference image as an `http://` or `https://` URL, a base64 string, or a base64 data URI. Must be a raster image (JPEG, PNG, WebP, HEIF, HEIC, or AVIF), cannot be SVG, and must be under 8 MB |
| `strength` | number | No | How strongly the reference guides the output, from `0.1` to `1`. Defaults to `0.5`. Ignored by models where `supportsStyleReferenceStrength` is `false` |

Support is per model. Check `GET /models?type=image`:

* `model_spec.supportsStyleReferences` is `true` only on models that accept the field.
* `model_spec.constraints.maxStyleReferences` is the number of entries the model accepts.
* `model_spec.constraints.supportsStyleReferenceStrength` tells you whether `strength` has any effect.

```bash theme={"system"}
curl -s "https://api.venice.ai/api/v1/models?type=image" \
  | jq -r '.data[] | select(.model_spec.supportsStyleReferences == true) | "\(.id) max=\(.model_spec.constraints.maxStyleReferences)"'
```

Sending `style_references` to a model without support returns `400`, as does exceeding that model's cap or sending a corrupt, unreachable, or oversized reference. Some models charge a style-reference fee for each returned image on top of the base image price — for example, Krea v2 Large and Krea v2 Medium. The fee is only charged for images that are actually returned. See [Image Models](https://docs.venice.ai/models/image.md) for the base per-image prices.

### Partial variant results

With `variants` greater than `1`, individual variants can be rejected by the provider's content policy while the rest succeed. In that case the endpoint still returns `200` with fewer images than you requested:

* When one or more variants are omitted, the JSON body includes `content_policy_violation_count`, the number of omitted variants.
* The `x-venice-content-violation-count` response header carries the same count.
* `x-venice-is-content-violation` and `x-venice-is-blurred` describe the images that were returned.

If every requested variant is rejected, no images are returned and the request fails with `422` instead. Do not assume `len(images) == variants`; compare the array length to `variants` and, when present, check `content_policy_violation_count`.

***

## OpenAI-compatible endpoint

If you're already using OpenAI image SDKs or existing DALL-E integrations, Venice also supports `POST /images/generations`. It offers a simpler request format, but fewer features than the native Venice endpoint.

**Request:**

```json theme={"system"}
{
  "model": "z-image-turbo",
  "prompt": "A clean isometric illustration of an AI control room",
  "size": "1024x1024",
  "response_format": "b64_json"
}
```

`size` only applies to pixel-sized models, which have a `widthHeightDivisor` above `1` in `model_spec.constraints` from `GET /models?type=image`. Most models, including `qwen-image-2`, size output by aspect ratio and resolution instead and ignore `size`.

Some OpenAI parameters are accepted for SDK compatibility but are ignored (`n` is restricted to `1`):

| Parameter | Behavior on `/images/generations` |
| - | - |
| `quality` | Accepted and ignored. Billing uses the model's default quality tier |
| `style` | Accepted and ignored |
| `output_compression` | Accepted and ignored |
| `user` | Accepted, discarded, and not an alias of `anon_user_id` |
| `n` | Only `1` is supported; other values are rejected by validation |

Tier control does not exist on this route: there is no `resolution` or `aspect_ratio` field, and `quality` cannot raise or lower the charge. For tiered GPT Image models, use the native `/image/generate` endpoint when you need to choose `quality`, `resolution`, or `aspect_ratio`.

Use the OpenAI-compatible route for faster migrations. Use `/image/generate` when you need Venice-specific options such as `cfg_scale`, `style_preset`, `style_references`, `variants`, or binary responses.

### Controlling adult-content blur on `/images/generations`

The OpenAI-compatible endpoint does not accept `safe_mode`. Sending it returns a `400` with `Unrecognized key(s) in object: 'safe_mode'`. Use the OpenAI-style `moderation` parameter instead:

| Value | Behavior |
| - | - |
| `auto` (default) | Blurs adult content, same as `safe_mode: true` |
| `low` | Returns unblurred output, same as `safe_mode: false` |

```json theme={"system"}
{
  "model": "lustify-v8",
  "prompt": "…",
  "size": "1024x1024",
  "response_format": "b64_json",
  "moderation": "low"
}
```

`safe_mode` only works on the native `POST /image/generate` endpoint. `moderation` only works on the OpenAI-compatible `POST /images/generations` endpoint.

The same split applies to transparency: `/image/generate` uses `transparent_background: true`, while `/images/generations` uses the OpenAI-style `background: "transparent"`. Both require a `png` or `webp` output format and a model with `supportsTransparentBackground: true`. See [Transparent Background Images](https://docs.venice.ai/guides/media/transparent-backgrounds.md).

***

## Prompting tips

1. Start with the subject, then add medium, lighting, composition, and mood.
2. Put must-avoid details in `negative_prompt` instead of overloading the main prompt.
3. Reuse `seed` when iterating so you can compare prompt changes without fully changing the composition.
4. Keep sizing model-aware. Some models use `width`/`height`, some use `aspect_ratio`, and resolution-tier models use `aspect_ratio` plus `resolution`.
5. Use `variants` during exploration, then switch back to a single output once you've locked in the direction.

***

## Errors

| Status | Meaning | Action |
| - | - | - |
| `400` | Invalid request parameters | Check field names, types, and model-specific constraints |
| `401` | Authentication failed or model requires a higher access tier | Check your API key and model access |
| `402` | Insufficient balance | Add credits at [venice.ai/settings/api](https://venice.ai/settings/api?utm_source=venice-api-documentation) |
| `404` | Unknown model | Check the model ID against `GET /models?type=image` |
| `415` | Invalid content type | Send JSON with `Content-Type: application/json` |
| `422` | Content policy violation | The provider explicitly rejected the prompt or image. Adjust the prompt or switch models. The body includes `error` and a boolean `retryable`, and may also include `suggested_prompt` and `recommended_model` |
| `429` | Rate limit exceeded or model overloaded | Retry with backoff; check `Retry-After` header |
| `500` | Inference processing failed | Retry the request |
| `503` | Model at capacity | Retry after a short delay |

> [!NOTE]
>
> When `safe_mode` is enabled (or `moderation` is `auto`), inspect response headers such as `x-venice-is-blurred` and `x-venice-is-content-violation` if you need to detect moderation outcomes programmatically.

***

## Available Models

See [Image Models](https://docs.venice.ai/models/image.md) for the current model list, pricing, and feature support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.