الانتقال إلى المحتوى الرئيسي
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>"
}

خيارات الأبعاد

تستخدم نماذج الصور معاملات أبعاد خاصة بكل نموذج:
  • النماذج المعتمدة على البكسل تقبل width و height، على سبيل المثال venice-sd35 و qwen-image.
  • نماذج نسبة العرض إلى الارتفاع تقبل aspect_ratio، على سبيل المثال qwen-image-2.
  • نماذج مستوى الدقة تقبل كلًا من aspect_ratio و resolution.
على سبيل المثال، gpt-image-2 و nano-banana-2 و nano-banana-pro تدعم قيم resolution من 1K و 2K و 4K:
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "4K",
  "format": "png"
}
ينطبق نمط أبعاد مستوى الدقة نفسه أيضًا على نماذج Nano Banana:
{
  "model": "nano-banana-pro",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
للنماذج التي تقبل نسبة العرض إلى الارتفاع لكنها لا تعرض مستويات الدقة، أرسل aspect_ratio بدون resolution:
{
  "model": "qwen-image-2",
  "prompt": "a serene canal in venice at sunset",
  "aspect_ratio": "16:9"
}
للنماذج التي تستخدم أبعاد البكسل المباشرة، أرسل width و height بدلًا من ذلك:
{
  "model": "venice-sd35",
  "prompt": "a serene canal in venice at sunset",
  "width": 1024,
  "height": 1024
}
تحقق من نماذج الصور أو endpoint النماذج لمعرفة خيارات الأبعاد المدعومة لكل نموذج قبل خلط حقول الأبعاد بين النماذج.

مستويات الجودة

تقبل بعض النماذج معاملًا اختياريًا quality (low أو medium أو high) يوازن بين دقة الصورة المرئية والتكلفة. مدعوم حاليًا من gpt-image-2؛ تتجاهل النماذج الأخرى المعامل.
{
  "model": "gpt-image-2",
  "prompt": "a cinematic wide shot of Venice at sunset",
  "aspect_ratio": "16:9",
  "resolution": "2K",
  "quality": "medium"
}
عند حذف quality، يستخدم النموذج مستواه الافتراضي (high لـ gpt-image-2). يعتمد التسعير على مجموعة resolution و quality — تُعرَض الأسعار لكل مستوى لـ gpt-image-2 (1K/2K/4K × low/medium/high) ضمن model_spec.pricing.quality في endpoint النماذج ومذكورة في نظرة عامة على التسعير.
التسعير المُدرِك للجودة هو الإعداد الافتراضي لجميع مستدعي API و SDK — لا يلزم header للموافقة. يتم احتساب الطلبات التي تحذف quality بالسعر الافتراضي للنموذج (high لـ gpt-image-2).

مجموعة Postman

للمزيد من الأمثلة، يرجى مراجعة مجموعة Postman هذه.

التفويضات

Authorization
string
header
مطلوب

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

الترويسات

Accept-Encoding
string

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

مثال:

"gzip, br"

الجسم

application/json
model
string
مطلوب

The model to use for image generation.

مثال:

"grok-imagine-image"

prompt
string
مطلوب

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
مثال:

"A beautiful sunset over a mountain range"

cfg_scale
number

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

النطاق المطلوب: 0 < x <= 20
مثال:

7.5

embed_exif_metadata
boolean
افتراضي:false

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

مثال:

false

format
enum<string>
افتراضي:webp

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

الخيارات المتاحة:
jpeg,
png,
webp
مثال:

"webp"

height
integer
افتراضي:1024

Height of the generated image.

النطاق المطلوب: 0 < x <= 1280
مثال:

1024

hide_watermark
boolean
افتراضي:false

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

مثال:

false

inpaint
any | null
مهمل

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.

النطاق المطلوب: 0 <= x <= 100
مثال:

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
مثال:

"Clouds, Rain, Snow"

return_binary
boolean
افتراضي:false

Whether to return binary image data instead of base64.

مثال:

false

variants
integer

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

النطاق المطلوب: 1 <= x <= 4
مثال:

3

safe_mode
boolean
افتراضي:true

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

مثال:

false

seed
integer
افتراضي:0

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

النطاق المطلوب: -999999999 <= x <= 999999999
مثال:

123456789

steps
integer
افتراضي:8

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

مثال:

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.

مثال:

"3D Model"

aspect_ratio
string

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

مثال:

"1:1"

resolution
string

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

مثال:

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

الخيارات المتاحة:
low,
medium,
high
مثال:

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

مثال:

false

width
integer
افتراضي:1024

Width of the generated image.

النطاق المطلوب: 0 < x <= 1280
مثال:

1024

الاستجابة

Successfully generated image

id
string
مطلوب

The ID of the request.

مثال:

"generate-image-1234567890"

images
string[]
مطلوب

Base64 encoded image data.

timing
object
مطلوب
request
any | null

The original request data sent to the API.