Generate Images
Create images given a prompt. Learn more.
Quick Start
This generic interface is used for OpenAI image models; GPT Image 2, Universal Sync Image, and Imagen within the project also reuse /v1/images/generations, selecting model extension parameters according to the corresponding model page.
| Type | Model |
|---|---|
| OpenAI | dall-e-2, dall-e-3, gpt-image-1, gpt-image-1-mini, gpt-image-1.5, chatgpt-image-latest |
| GPT Image 2 | gpt-image-2, gpt-image-2-vip, gpt-image-2-1k, gpt-image-2-2k, gpt-image-2-4k |
| Universal Sync Image | z-image, z-image-turbo, qwen-image, wan2.6, wan2.7-image, wan2.7-image-pro |
| Imagen | imagen-4.0-generate-001, imagen-4.0-ultra-generate-001, imagen-4.0-fast-generate-001 |
| Gemini Image Chat | gemini-2.0-flash-exp-image-generation, gemini-2.0-flash-exp, gemini-2.5-flash-image, gemini-3-pro-image-preview, gemini-3.1-flash-image-preview |
curl "$BASE_URL/v1/images/generations" \
-H "Authorization: Bearer $NODEKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A product poster of a red mountain bike, white background, clear studio shot",
"size": "1024x1024",
"quality": "medium",
"n": 1,
"response_format": "url"
}'from openai import OpenAI
client = OpenAI(api_key="sk-xxx", base_url="https://nodekey.xinghanyun.cn/v1")
image = client.images.generate(
model="gpt-image-2",
prompt="A product poster of a red mountain bike, white background, clear studio shot",
size="1024x1024",
quality="medium",
n=1,
)
print(image.data[0].url)Image editing goes through /v1/images/edits; the Universal editing models include qwen-image-edit, qwen-image-edit-max, qwen-image-edit-plus and their dated versions. The Gemini image chat model goes through /v1/chat/completions or Gemini native generateContent.
Authorization
Bearer
In: header
Request Body
application/json
用于图像生成的模型。dall-e-2、dall-e-3 或 gpt-image-1 之一。默认为 dall-e-2,除非使用特定于 gpt-image-1 的参数。
所需图像的文本描述。gpt-image-1 的最大长度为 32000 个字符,dall-e-2 的最大长度为 1000 个字符,dall-e-3 的最大长度为 4000 个字符。
要生成的图像数量。必须介于 1 到 10 之间。对于 dall-e-3,仅支持 n=1。
生成的图像的大小。对于 gpt-image-1,必须是 1024x1024、1536x1024(横向)、1024x1536(纵向)或自动(默认值)之一,对于 dall-e-2,必须是 256x256、``512x512 或 1024x1024 之一,对于 dall-e-3,必须是 1024x1024、1792x1024 或 1024x1792 之一。
允许为生成的图像的背景设置透明度。此参数仅支持 gpt-image-1。必须是以下之一 透明、不透明或自动(默认值)。使用自动时,模型将自动确定图像的最佳背景。
如果是透明的,则输出格式需要支持透明度,因此应将其设置为 png(默认值)或 webp。
控制 gpt-image-1 生成的图像的内容审核级别。必须为低, 以进行限制较少的筛选或自动(默认值)。
将生成的图像的质量。
Response Body
application/json
curl -X POST "https://nodekey.xinghanyun.cn/v1/images/generations/" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "prompt": "把图片中的自行车改成红色,保持背景和构图不变", "n": 1 }'{
"created": 0,
"data": [
{
"b64_json": "string",
"url": "string"
}
],
"usage": {
"total_tokens": 0,
"input_tokens": 0,
"output_tokens": 0,
"input_tokens_details": {
"text_tokens": 0,
"image_tokens": 0
}
}
}Last updated on