API reference
Image generation
The Images API generates and edits images using the OpenAI-compatible images format. This article covers general usage. See the Media generation section for model capabilities and output comparisons.
Supported models
| Model | Positioning |
|---|---|
| See the Model Catalog (Models in the console) for image-generation models currently available | |
Image generation and editing use /v1/images/generations and /v1/images/edits. Change only the model parameter to a model currently available in the Model Catalog.
Image-generation endpoint
POST https://api.yomiapi.com/v1/images/generations
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID (use an available model from the Model Catalog) |
prompt | string | Yes | Prompt describing the image |
n | integer | No | Number of images; default 1 |
size | string | No | Output dimensions, such as 1024x1024; supported values depend on the model |
quality | string | No | Quality tier; supported values depend on the model |
response_format | string | No | Response format: url or b64_json, depending on the model's response |
Python example
import base64
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.yomiapi.com/v1"
)
response = client.images.generate(
model="your-image-model-id",
prompt="A cute orange cat sleeping in the sunshine",
size="1024x1024",
n=1
)
with open("cat.png", "wb") as f:
f.write(base64.b64decode(response.data[0].b64_json))
cURL example
curl https://api.yomiapi.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "your-image-model-id",
"prompt": "A cute orange cat sleeping in the sunshine",
"size": "1024x1024",
"n": 1
}'
Image-editing endpoint
POST https://api.yomiapi.com/v1/images/edits
The editing endpoint uploads the source image as multipart/form-data and modifies it according to the prompt. The platform does not provide the /v1/images/variations (image variations) endpoint.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
image | file | Yes | Source image file |
prompt | string | Yes | Editing instruction |
mask | file | No | Mask image specifying the area that may be modified |
n | integer | No | Number of images |
size | string | No | Output dimensions |
Python example
response = client.images.edit(
model="your-image-model-id",
image=open("input.png", "rb"),
prompt="Replace the background with a beach at dusk"
)
with open("edited.png", "wb") as f:
f.write(base64.b64decode(response.data[0].b64_json))
Prompt recommendations
- Describe details: Specify the subject, style, lighting and composition. More complete information makes the result easier to control.
- Specify a style: For example, oil painting, 3D rendering or minimalism, to keep the model from drifting from your intended result.
- Visual requirements: Use terms such as professional photography, shallow depth of field or high resolution to guide the visual treatment.
Example prompt:
A golden Labrador running on a beach,
its fur sparkling in the sunlight,
a blue ocean and sky in the background,
professional photography, high resolution, shallow depth of field
Billing and error handling
Generation commonly fails when the prompt triggers a content policy or parameters are invalid (400). Adjust the prompt and parameters before retrying. See API overview and authentication for common errors such as 401, 429 and 500. Model features, output comparisons and additional uses are covered in the Media generation section.
