You can generate product card images, newsletter banners and post covers from code: send a text description and receive a finished image. This guide covers the image generation API for models in the llmbox catalog, from your first request to a complete series of catalog cards. Models from OpenAI, Google and Qwen are available through the official openai SDK with one key and the base URL https://llmbox.cc/v1.
How to choose a model
The catalog has six image models, all available through the POST /v1/images/generations endpoint. They differ in the inputs they accept and the tasks they suit.
| Task | Model | Why |
|---|---|---|
| Illustrations, covers and product visuals from a description | GPT Image 2 | lets you set resolution and quality in the request and generate several variants at once |
| Your product in a new setting from a source photo | Gemini 3 Pro Image | accepts one or more reference photos and reproduces lettering |
| Many variations from a reference; a series of visuals | Gemini 3.1 Flash Image | Google's lighter model for fast, high-volume generation |
| A banner with a headline or caption | Qwen-Image-3.0 | renders crisp text in 12 languages and accepts long descriptions |
| A dense layout: menu, price list, poster | Qwen-Image-3.0 Pro | handles extensive text and fine details in a single pass |
| Images for feeds, stories and covers | Qwen-Image-2.1 | seven aspect ratios, from 1:1 to 16:9 |
Google also refers to Gemini 3 Pro Image as Nano Banana Pro, so use this model if you are looking for the Nano Banana Pro API. All image models and their prices are listed in the image model collection.
To choose a model, select two or three options from the table and send the same prompts to each. The code stays the same; only the model string changes.
How to set up the client
You need Python 3.10 or newer and the openai package. Create an llmbox key in the cabinet's Keys section; for details, see the Quickstart documentation page. Keep the key in an environment variable on your server. Users can inspect keys embedded in browser or mobile app code.
pip install openai
export LLMBOX_API_KEY="sk-your-key"
Image generation does not stream and can take minutes, so set a generous client timeout.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://llmbox.cc/v1",
api_key=os.environ["LLMBOX_API_KEY"],
timeout=600, # generation can take minutes
)
How to generate your first image with the GPT Image API
Let's start with a product shot from a text description. For GPT Image 2, the size is set with the resolution field (1K, 2K or 4K) and the quality with the quality field (low, medium or high). In the Python SDK, resolution is passed through extra_body.
curl https://llmbox.cc/v1/images/generations \
-H "Authorization: Bearer $LLMBOX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-image-2",
"prompt": "A white ceramic mug on a light wooden table, soft morning light, blurred background, product shot",
"n": 1,
"resolution": "1K",
"quality": "medium"
}'
The JSON response contains the image as a base64 string in data[0].b64_json. Save the file to disk or your own cloud storage.
{
"created": 1790000000,
"data": [{"b64_json": "iVBORw0KGgo..."}]
}
How to create a product photo: the Nano Banana Pro API
When the image must show your actual product rather than a similar one, use a model that accepts images as input: Gemini 3 Pro Image or Gemini 3.1 Flash Image. Pass the product photo as a reference and describe what to do with it, such as placing it in an interior, changing the background or adding props.
Pass one reference in the image field as a link or a base64 data: URL. Pass several references, such as a product and a background, as a list in the images field. Use one field per request: either image or images. The request body limit is 90 MiB.
import base64
from client import client
with open("sneaker.jpg", "rb") as f:
photo = "data:image/jpeg;base64," + base64.b64encode(f.read()).decode()
resp = client.images.generate(
model="google/gemini-3-pro-image",
prompt="These sneakers on wet city asphalt in the evening, reflections "
"of neon signs, low angle. Do not change the shape, color or logo of the shoes.",
n=1,
extra_body={"image": photo},
)
with open("sneaker_city.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Practical tips:
- Use a clean source photo. The product should be fully in frame, evenly lit and free of other objects. That makes it easier for the model to move it into a new scene.
- Say what to preserve. Ending the prompt with "do not change the shape, color or logo" keeps the model from "improving" the product itself.
- Keep the style consistent across the series. For a catalog, pass a successful finished image as a second reference and ask the model to repeat its lighting and background. Gemini 3.1 Flash Image works well for generating this kind of series.
How to create a banner with text
Rendering text in an image is a separate challenge: the lettering must be readable and undistorted. Qwen-Image-3.0 works well for banners. According to Alibaba's documentation, it renders crisp text as small as 10 pixels in 12 languages and accepts descriptions of up to 4,500 tokens. Gemini 3 Pro Image also handles short captions. If the layout has dozens of lines, such as a price list, menu or poster, compare the result with Qwen-Image-3.0 Pro.
import base64
from client import client
prompt = (
"A horizontal advertising banner for an online tea shop. "
"On the left, a glass teapot with green tea on a light background; on the right, empty space. "
'In the empty space, a large headline "New harvest" and a line below it "Discount on your first order". '
"Sans-serif font, dark green text, plenty of white space, no extra details."
)
resp = client.images.generate(model="qwen/qwen-image-3.0", prompt=prompt, n=1)
with open("banner.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Banner tips:
- Put the exact text in quotes. Write the final wording of the caption and wrap it in quotes so it does not blend with the scene description.
- Set aside space for the text. "Product on the left, empty space for the headline on the right" keeps the lettering from landing on top of the subject.
- Shorter is more reliable. A two- or three-word headline and a single caption line are easier to read than a paragraph. Longer text, prices and buttons are often easier to overlay on the finished image in your layout.
The aspect ratio is set in the request, but the fields differ between models: some accept aspect_ratio, while others set the size through image_size. A field the model does not recognize can cause a 400 error. Before changing models, check the Images documentation page and the model's page.
How to create a series of catalog cards
When you need many images, separate drafting from final production. First generate several variants at low quality and choose the best one, then generate it again at high quality and a higher resolution. The n field accepts values from 1 to 10.
import base64, csv
from client import client
STYLE = "product shot, white background, soft shadow, product in the center"
with open("products.csv", encoding="utf-8") as f:
for row in csv.DictReader(f): # columns: sku, name
resp = client.images.generate(
model="openai/gpt-image-2",
prompt=f"{row['name']}, {STYLE}",
n=3,
quality="low",
extra_body={"resolution": "1K"},
)
for i, item in enumerate(resp.data):
with open(f"{row['sku']}_draft{i + 1}.png", "wb") as out:
out.write(base64.b64decode(item.b64_json))
The shared part of the prompt in the STYLE constant gives the entire series a consistent look: the same background, lighting and angle. Once a draft is approved, repeat the same prompt with quality="high" and resolution set to 2K or 4K for a large screen or print.
In a production application, run generation in the background: queue the job, save the result to your own storage and show the user the finished file. This keeps the interface from waiting for the model.
How to write a prompt for a product
A good product-image prompt describes five elements: the object, setting, lighting, camera angle and style. For example: "A glass bottle of olive oil (object) on a stone countertop next to a sprig of rosemary (scene), warm side light from a window (lighting), side view at table level (angle), photorealistic, shallow depth of field (style)."
If writing detailed descriptions for a hundred products takes too long, use a text model. For example, GPT-5.6 Luna accepts images as input: send it a product photo and ask it to describe a scene for generation. Pass the resulting description to GPT Image 2 with the same client and key. For Qwen-Image, Qwen3.8 Flash can prepare the description.
How to handle errors
| HTTP | code | What to do |
|---|---|---|
| 400 | content_policy_violation | The prompt was rejected by the content policy. Rephrase it. |
| 400 | invalid_image | The model rejected the reference. Try a different photo. |
| 422 | generation_failed | The model did not return an image. Repeat the request or refine the prompt. |
The other codes are described in the Errors documentation page.
How to estimate the cost
Each image you receive is charged to your balance based on actual usage. Most image models have a single price per image. For GPT Image 2, the price depends on resolution and quality: a low-quality draft costs less than a 4K final. For details, see the news post Images: the price depends on resolution and quality.
Current prices and a calculator are on each model's page: GPT Image 2, Gemini 3 Pro Image, Gemini 3.1 Flash Image, Qwen-Image-3.0, Qwen-Image-3.0 Pro and Qwen-Image-2.1. To estimate the budget for a series, multiply the number of products by the number of variants and the chosen model's per-image price. The actual cost of each request is shown in the Logs section of the cabinet, and totals by day and model are in the Usage section.
Where to go next
All request fields and endpoint details are in the Images documentation page, and working with the SDK in other languages is covered in OpenAI and ElevenLabs SDKs. To animate an image, you can create videos with the same key; see the article Video through the API: Veo 3.1, Kling and Seedance. To compare image models by price and capabilities, open the model collection.
Questions
Do I need a separate OpenAI or Google key to generate images?
No. You can call every image model in the catalog with one llmbox key and select the model using the model string in the request.
Which models can use a photo of my product?
Gemini 3 Pro Image and Gemini 3.1 Flash Image accept images as input. Pass the product photo in the image field and describe the setting you want to show it in.
How is the image returned?
The image is returned as a base64 string in the response's data[].b64_json field. Decode it and save it to a file or your own storage.
How do I get several variants at once?
Set the n field to a value from 1 to 10. You pay for each image you receive, so compare variants at low quality and resolution.
Where can I see what a request cost?
The cost of each request is shown in the Logs section of the cabinet, and totals by day and model are in the Usage section.
Published November 15, 2026


