Image Generation
Generate and edit images with OpenAI-compatible Images endpoints.
Yunxin exposes the OpenAI Images API across every provider that supports image generation. Pick a
model with the Models API (GET /v1/models?type=image_generation) and call the same
two endpoints regardless of provider.
Which parameters and values a model accepts (sizes, qualities, styles, n range) is per-model.
Unsupported options are ignored or rejected upstream — query the model's capabilities via the
Models API rather than assuming a fixed set.
Generate images
POST /v1/images/generationsRequest
{
"model": "model-id",
"prompt": "A serene mountain landscape at sunset, digital art",
"n": 1,
"size": "1024x1024",
"quality": "standard",
"response_format": "url"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image model id. |
prompt | string | Yes | Text description of the image (up to 4000 chars). |
n | integer | No | Number of images to generate (1–10). Default 1. |
size | string | No | Image size, e.g. 1024x1024. Default 1024x1024. |
quality | string | No | Render quality, e.g. standard or hd (model-dependent). |
style | string | No | Style hint, e.g. vivid or natural (model-dependent). |
response_format | string | No | url (default) or b64_json. |
negative_prompt | string | No | What to avoid (model-dependent). |
seed | integer | No | Seed for reproducibility (model-dependent). |
Some diffusion models also accept width/height, steps, guidance_scale, and strength. These are
provider-specific and validated upstream; rely on GET /v1/models/{model_id} for what a given model
honors.
Response
{
"created": 1709251200,
"data": [
{
"url": "https://api.yuhuanstudio.com/v1/temp-images/abc123.png",
"revised_prompt": "A serene mountain landscape at sunset, digital art"
}
]
}With response_format: "b64_json", each item carries b64_json instead of url.
Edit images
POST /v1/images/editsEdit or inpaint an existing image. Send the source image (and an optional mask) as multipart form
data along with a prompt:
response = client.images.edit(
model="model-id",
image=open("original.png", "rb"),
mask=open("mask.png", "rb"),
prompt="Replace the sky with a starry night",
n=1,
size="1024x1024",
)
print(response.data[0].url)The mask is optional; where supported, its transparent pixels mark the region to regenerate.
Examples
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url="https://api.yuhuanstudio.com/v1",
)
response = client.images.generate(
model="model-id",
prompt="A futuristic city with flying cars, cyberpunk style",
size="1024x1024",
n=1,
)
print(response.data[0].url)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.YUNXIN_API_KEY,
baseURL: "https://api.yuhuanstudio.com/v1",
});
const response = await client.images.generate({
model: "model-id",
prompt: "A futuristic city with flying cars, cyberpunk style",
size: "1024x1024",
n: 1,
});
console.log(response.data[0].url);curl https://api.yuhuanstudio.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $YUNXIN_API_KEY" \
-d '{
"model": "model-id",
"prompt": "A futuristic city with flying cars, cyberpunk style",
"size": "1024x1024",
"n": 1
}'Image models
List available image models and their capabilities with the Models API:
GET /v1/models?type=image_generation. To analyze images as input to a chat model, see
Vision instead.
How is this guide?