venice-image-generate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVenice Image Generation
Venice 图像生成
Two text-to-image endpoints:
- — Venice-native, full control (negative prompts, CFG, seed, up to 4 variants).
POST /api/v1/image/generate - — OpenAI-compatible, fewer knobs but drop-in for the OpenAI SDK.
POST /api/v1/images/generations
Plus:
- — list of style preset names for
GET /api/v1/image/styles.style_preset
For editing / upscaling / multi-image / background removal, see .
venice-image-edit两个文本转图像接口:
- — Venice原生接口,支持完全控制(负提示词、CFG、种子值、最多4个变体图像)。
POST /api/v1/image/generate - — 兼容OpenAI接口,可调节参数较少,但可直接替换OpenAI SDK使用。
POST /api/v1/images/generations
额外接口:
- — 获取可用于
GET /api/v1/image/styles的风格预设名称列表。style_preset
如需编辑/超分辨率/多图像处理/背景移除功能,请查看。
venice-image-editUse when
适用场景
- You need to generate images from text prompts.
- You need multiple variants in one call.
- You're porting from OpenAI's and want a zero-change SDK swap.
images.generate - You want to browse style presets before committing to one.
- 你需要通过文本提示生成图像。
- 你需要在一次调用中生成多个变体图像。
- 你正在迁移OpenAI的功能,希望实现SDK零改动替换。
images.generate - 你想在确定使用某一风格前浏览所有风格预设。
/image/generate
— Venice-native
/image/generate/image/generate
— Venice原生接口
/image/generateRequest
请求示例
bash
curl https://api.venice.ai/api/v1/image/generate \
-H "Authorization: Bearer $VENICE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-image-turbo",
"prompt": "A beautiful sunset over a mountain range",
"width": 1024,
"height": 1024,
"cfg_scale": 7.5,
"steps": 8,
"seed": 123456789,
"variants": 1,
"format": "webp",
"style_preset": "3D Model",
"safe_mode": true
}'bash
curl https://api.venice.ai/api/v1/image/generate \
-H "Authorization: Bearer $VENICE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-image-turbo",
"prompt": "A beautiful sunset over a mountain range",
"width": 1024,
"height": 1024,
"cfg_scale": 7.5,
"steps": 8,
"seed": 123456789,
"variants": 1,
"format": "webp",
"style_preset": "3D Model",
"safe_mode": true
}'Fields
请求字段
| Field | Type | Default | Notes |
|---|---|---|---|
| string | — | Required. Image model ID. |
| string | — | Required. Max |
| string | — | Describe what not to show. Same character cap as prompt. |
| int | 1024, 1024 | ≤ 1280 each. Must be divisible by |
| string | — | |
| string | — | |
| number | model default | 0 < x ≤ 20. Higher = more prompt adherence. |
| int | 8 | Inference steps. Some models ignore it (e.g. Turbo). |
| int | 0 | |
| int | 1 | 1–4. Only if |
| int | — | 0–100 when model uses Loras. |
| string | — | Value from |
| | | Response image format. |
| bool | | |
| bool | | Embed prompt info in EXIF. |
| bool | | Venice may still watermark certain content. |
| bool | | Blurs adult content. |
| bool | | Only some models. Charges extra. |
| — | — | Deprecated since May 19 2025. A new inpaint API is forthcoming. |
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| string | — | 必填项。图像模型ID。可通过 |
| string | — | 必填项。最大长度由模型 |
| string | — | 描述不需要出现在图像中的内容。长度限制与 |
| int | 1024, 1024 | 各自最大值≤1280。必须能被模型 |
| string | — | |
| string | — | |
| number | 模型默认值 | 0 < x ≤ 20。数值越高,图像与提示词的贴合度越高。 |
| int | 8 | 推理步数。部分模型会忽略该参数(如Turbo系列)。 |
| int | 0 | 取值范围 |
| int | 1 | 取值范围1–4。仅当 |
| int | — | 当模型使用Loras时,取值范围0–100。 |
| string | — | 值来自 |
| | | 响应图像的格式。 |
| bool | | |
| bool | | 在EXIF中嵌入提示词信息。 |
| bool | | 对于特定内容,Venice仍可能添加水印。 |
| bool | | 对成人内容进行模糊处理。 |
| bool | | 仅部分模型支持。会额外收费。 |
| — | — | 已废弃(自2025年5月19日起)。新的inpaint API即将推出。 |
Response (JSON, return_binary: false
)
return_binary: false响应示例(JSON格式,return_binary: false
)
return_binary: falsejson
{
"id": "...",
"images": ["<base64>", "<base64>"],
"timing": {...},
"request": {...}
}With , response is raw (or /) with matching .
return_binary: trueimage/webppngjpegContent-Typejson
{
"id": "...",
"images": ["<base64>", "<base64>"],
"timing": {...},
"request": {...}
}当时,响应为原始(或/)格式,同时匹配对应的头。
return_binary: trueimage/webppngjpegContent-Type/images/generations
— OpenAI-compatible
/images/generations/images/generations
— 兼容OpenAI接口
/images/generationsUse this if you're already on the OpenAI SDK. Field names match .
openai.images.generate()ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.VENICE_API_KEY,
baseURL: 'https://api.venice.ai/api/v1',
})
const res = await client.images.generate({
model: 'z-image-turbo',
prompt: 'A beautiful sunset over mountain ranges',
size: '1024x1024',
response_format: 'b64_json',
})
const b64 = res.data[0].b64_json如果你已在使用OpenAI SDK,可使用此接口。字段名称与完全匹配。
openai.images.generate()ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.VENICE_API_KEY,
baseURL: 'https://api.venice.ai/api/v1',
})
const res = await client.images.generate({
model: 'z-image-turbo',
prompt: 'A beautiful sunset over mountain ranges',
size: '1024x1024',
response_format: 'b64_json',
})
const b64 = res.data[0].b64_jsonMapped fields
字段映射
| Field | Values | Notes |
|---|---|---|
| string, default | Unknown model IDs fall back to Venice's default. |
| string, ≤ 1500 chars | Required. |
| | — |
| | Defaults to |
| | |
| | — |
| | Venice only supports a single image per call here. |
| — | Accepted for OpenAI compat, not used by Venice. |
If you need , , , , or , switch to .
variantsseednegative_promptcfg_scalestyle_preset/image/generate| 字段 | 取值 | 说明 |
|---|---|---|
| string,默认值 | 未知模型ID会 fallback 到Venice的默认模型。 |
| string,≤1500字符 | 必填项。 |
| | — |
| | 默认值为 |
| | |
| | — |
| | Venice在此接口中仅支持单次调用生成单张图像。 |
| — | 为兼容OpenAI而保留,但Venice不会使用这些参数。 |
如果你需要、、、或参数,请切换到接口。
variantsseednegative_promptcfg_scalestyle_preset/image/generate/image/styles
— list presets
/image/styles/image/styles
— 获取风格预设列表
/image/stylesbash
curl https://api.venice.ai/api/v1/image/styles \
-H "Authorization: Bearer $VENICE_API_KEY"Returns a list of , each with a you can pass to . Cache this — it's small and stable.
styles[]namestyle_presetbash
curl https://api.venice.ai/api/v1/image/styles \
-H "Authorization: Bearer $VENICE_API_KEY"返回列表,每个元素包含可传入的值。建议缓存此结果——内容体量小且稳定。
styles[]style_presetnameChoosing a model
模型选择方法
bash
curl "https://api.venice.ai/api/v1/models?type=image" \
-H "Authorization: Bearer $VENICE_API_KEY"Inspect per-model :
model_spec- —
constraints.widthHeightDivisorandwidthmust both be divisible by this.height - +
constraints.aspectRatios[]— if present, the model supports aspect-ratio-driven sizing.defaultAspectRatio - +
constraints.resolutions[]— if present, the model supportsdefaultResolution(resolution/1K/2K).4K - — step bounds (some models ignore
constraints.steps.{default,max}entirely).steps - — max prompt length (also applies to
constraints.promptCharacterLimit).negative_prompt - — flat USD per image, or
pricing.generation.usdfor resolution-tiered models.pricing.resolutions[].usd
Pick a model that matches the feature + size combo you plan to use.
bash
curl "https://api.venice.ai/api/v1/models?type=image" \
-H "Authorization: Bearer $VENICE_API_KEY"查看每个模型的:
model_spec- —
constraints.widthHeightDivisor和width必须能被此值整除。height - +
constraints.aspectRatios[]— 如果存在,说明模型支持按宽高比设定尺寸。defaultAspectRatio - +
constraints.resolutions[]— 如果存在,说明模型支持defaultResolution参数(resolution/1K/2K)。4K - — 步数范围(部分模型会完全忽略
constraints.steps.{default,max}参数)。steps - — 提示词最大长度(同样适用于
constraints.promptCharacterLimit)。negative_prompt - — 单张图像的固定美元费用;对于按分辨率分层定价的模型,费用在
pricing.generation.usd中。pricing.resolutions[].usd
选择与你计划使用的功能+尺寸组合匹配的模型。
Common patterns
常见使用模式
Fixed-seed A/B test
固定种子值的A/B测试
json
{"model": "z-image-turbo", "prompt": "...", "seed": 42, "variants": 4}json
{"model": "z-image-turbo", "prompt": "...", "seed": 42, "variants": 4}Aspect-ratio-driven model (Nano Banana family)
按宽高比驱动的模型(Nano Banana系列)
json
{"model": "nano-banana-2", "prompt": "...", "aspect_ratio": "16:9", "resolution": "2K"}(Other nano-banana variants: . Always verify the current ID via .)
nano-banana-proGET /models?type=imagejson
{"model": "nano-banana-2", "prompt": "...", "aspect_ratio": "16:9", "resolution": "2K"}(其他Nano Banana变体:。请始终通过验证当前模型ID。)
nano-banana-proGET /models?type=imageStyle preset + negative
风格预设+负提示词
json
{
"model": "z-image-turbo",
"prompt": "a red sports car in a parking lot",
"negative_prompt": "blurry, people, clouds",
"style_preset": "3D Model"
}json
{
"model": "z-image-turbo",
"prompt": "a red sports car in a parking lot",
"negative_prompt": "blurry, people, clouds",
"style_preset": "3D Model"
}Stream binary to disk (Node)
将二进制流写入磁盘(Node.js)
ts
const res = 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: 'z-image-turbo', prompt: '...', return_binary: true }),
})
if (!res.ok) throw new Error(await res.text())
const buf = Buffer.from(await res.arrayBuffer())
await fs.writeFile('out.webp', buf)ts
const res = 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: 'z-image-turbo', prompt: '...', return_binary: true }),
})
if (!res.ok) throw new Error(await res.text())
const buf = Buffer.from(await res.arrayBuffer())
await fs.writeFile('out.webp', buf)Errors
错误码说明
| Code | Meaning |
|---|---|
| Bad params (e.g. dimensions not divisible by |
| Auth or Pro-only model. |
| Insufficient balance. Bearer: plain |
| Wrong |
| Rate limited. |
| Inference or capacity issue — retry with jitter. |
(Content-policy violations on come back as with an error string, not — the shape is specific to audio generation paths.)
/image/generate400422422| 状态码 | 含义 |
|---|---|
| 参数错误(例如:尺寸无法被 |
| 认证失败或使用了仅Pro用户可用的模型。 |
| 余额不足。Bearer认证返回: |
| |
| 请求频率超限。 |
| 推理或容量问题 — 请添加抖动后重试。 |
(接口的内容政策违规会返回及错误字符串,而非 — 状态码专用于音频生成路径的错误。)
/image/generate400422422Gotchas
注意事项
- Each model picks one sizing idiom: either /
width,height+aspect_ratio, or (OpenAI-compat)resolution. Match the model'ssize.constraints - requires
variants > 1(JSON with base64 array).return_binary: false - is ignored by fast/turbo models; they hardcode step count internally.
steps - is advisory — Venice may still watermark content flagged by safety classifiers.
hide_watermark: true - Old field is deprecated; don't use it.
inpaint - For OpenAI-compat, returns a data URL, not a hosted URL — plan for that if you're saving to storage.
response_format: "url"
- 每个模型仅支持一种尺寸设定方式:要么是/
width,要么是height+aspect_ratio,要么是(兼容OpenAI的)resolution。请匹配模型的size参数。constraints - 要求
variants > 1(返回包含base64数组的JSON)。return_binary: false - 快速/Turbo系列模型会忽略参数;它们在内部硬编码了步数。
steps - 仅为建议性设置 — 对于被安全分类器标记的内容,Venice仍可能添加水印。
hide_watermark: true - 旧的字段已废弃,请不要使用。
inpaint - 在兼容OpenAI的接口中,返回的是data URL,而非托管URL — 如果要保存到存储系统,请对此做好适配。
response_format: "url"