Image generation and edits
Generate and edit images on BigModel.io with the OpenAI-compatible /v1/images/generations and /v1/images/edits endpoints, priced per image.
On this page
Image models use the OpenAI Images API. The request waits until the images are ready and returns them in one response. You pay per image returned; images that fail are not charged.
| Task | Request | Price |
|---|---|---|
| Text to image | POST /v1/images/generations |
per image |
| Edit, restyle, upscale or cut out an image | POST /v1/images/edits |
per image |
Find model IDs and prices under Models → Image. Availability depends on your key's group: GET /v1/models lists what your key can call.
#Generate an image
curl https://bigmodel.io/v1/images/generations \
-H "Authorization: Bearer $BIGMODEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.1",
"prompt": "A paper lantern floating over a misty lake at dawn, the words \"Good Morning\" painted on it",
"size": "1536x1024",
"n": 1
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://bigmodel.io/v1", api_key=os.environ["BIGMODEL_API_KEY"])
result = client.images.generate(
model="qwen-image-2.1",
prompt="A paper lantern floating over a misty lake at dawn",
size="1536x1024",
)
print(result.data[0].url)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://bigmodel.io/v1", apiKey: process.env.BIGMODEL_API_KEY });
const result = await client.images.generate({
model: "qwen-image-2.1",
prompt: "A paper lantern floating over a misty lake at dawn",
size: "1536x1024",
});
console.log(result.data[0].url);The response is {"created": 1760000000, "data": [{"url": "https://bigmodel.io/v1/media/..."}]}. The link works without an API key for 24 hours; download the file if you need it longer, and treat the link as private.
#Request fields
| Field | Notes |
|---|---|
model |
Required. An image model ID. |
prompt |
Required for generation; optional for tools such as image-upscale. |
size |
WIDTHxHEIGHT, for example 1024x1024 or 1536x1024. It sets the aspect ratio and the quality tier: a longest side under 1800 px is 1K, from 1800 px 2K, from 3500 px 4K. The model's own limits apply. |
n |
1 to 4 images. Each image is generated and charged separately. |
response_format |
url (default) or b64_json to get the image bytes inline. |
background |
transparent for a transparent PNG on models that support it (the model note says so). |
stream is not supported for these models.
#Edit an image
Send one or more input images with an instruction. Inputs can be public https:// URLs or base64 data URIs (data:image/png;base64,...), up to 50 MB each and 10 per request.
curl https://bigmodel.io/v1/images/edits \
-H "Authorization: Bearer $BIGMODEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.1",
"prompt": "Make it a snowy winter evening, keep the composition",
"images": [{"image_url": "https://example.com/street.jpg"}]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://bigmodel.io/v1", api_key=os.environ["BIGMODEL_API_KEY"])
with open("street.jpg", "rb") as image:
result = client.images.edit(
model="qwen-image-2.1",
image=image,
prompt="Make it a snowy winter evening, keep the composition",
)
print(result.data[0].url)Multipart uploads (image, or image[] for several files) work too, which is what the OpenAI SDKs send. With several inputs, the first is the image to edit and the others are references.
Tool models take an input image and no prompt: image-upscale returns a larger copy, image-remove-background returns the subject on a transparent background.
#Use an image as a video's first frame
Most video models animate a first frame. Generate it here, then pass its URL as image to POST /v1/videos.
#Verify the setup
Run the generation example. A 200 with a data[0].url that opens an image means your key can use image models. The charge appears in Usage as one line per request.
#Troubleshooting
404: the model is not available. The model is not offered in your key's group. Check GET /v1/models, or use a key in a group that includes image models.
400 invalid_request_error: "An input image could not be read". The URL is not public https://, or the data URI is malformed or larger than 50 MB.
400: "This model edits images: send an input image". The model only edits. Call /v1/images/edits with an input image.
400: "n must be at most 4". Ask for at most 4 images per request.
502 upstream_error. The image could not be generated, often because of the prompt or input. The message says why when it is known. You are not charged for failed images.
403 billing_error. Your balance is used up. Top up in Billing.
#Related
- Video generation to animate the image.
- Image input (vision) to send images to chat models instead.
- Pricing for every image price.
Updated · View as Markdown