Image Generation
Generate and edit images using AI models.
Generate Images
POST /v1/images/generationsRequest
{
"model": "model-id",
"prompt": "A serene mountain landscape at sunset, digital art",
"n": 1,
"size": "1024x1024",
"quality": "hd"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Image model ID |
prompt | string | Yes | Text description of the image |
n | integer | No | Number of images (1–10) |
size | string | No | Image size (e.g., 1024x1024) |
quality | string | No | standard or hd |
style | string | No | natural or vivid |
response_format | string | No | url or b64_json |
Response
{
"created": 1709251200,
"data": [
{
"url": "https://api.yuhuanstudio.com/v1/temp-images/abc123.png",
"revised_prompt": "A serene mountain landscape..."
}
]
}Edit Images
POST /v1/images/editsEdit or inpaint existing images:
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"
)Examples
from openai import OpenAI
client = OpenAI(
api_key="YOUR_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",
quality="hd",
n=1,
)
print(response.data[0].url)const response = await client.images.generate({
model: "model-id",
prompt: "A futuristic city with flying cars, cyberpunk style",
size: "1024x1024",
quality: "hd",
n: 1,
});
console.log(response.data[0].url);curl https://api.yuhuanstudio.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "model-id",
"prompt": "A futuristic city with flying cars, cyberpunk style",
"size": "1024x1024",
"quality": "hd",
"n": 1
}'Image Models
For a list of available image models and their capabilities, please use the Models API with GET /v1/models?type=image_generation.
How is this guide?