LLM API Gateway Image Generation Guide
Learn the image generation endpoint, model selection, parameter settings, and request methods.
Image generation is now available through the LLM API Gateway.
You can generate images directly through one unified endpoint, whether you need WeChat Official Account covers, product illustrations, app icons, ecommerce images, or automatic illustrations for agents.
Image generation endpoint: POST https://api.llm-token.cn/v1/images/generations
1. Quick Start: Prepare These 3 Things ✨
| What You Need | What to Enter |
|---|---|
| LLM API Gateway access key | Add Authorization: Bearer 你的new-api-token to the request headers |
| Image generation endpoint | https://api.llm-token.cn/v1/images/generations |
| Image generation model | image-01 or image-01-live |
The LLM API Gateway brings model access, API compatibility, quota management, and billing rules together in one place. You only need your own LLM API Gateway access key to use image generation through a single endpoint.
2. Get It Working in 1 Minute: curl Example 🚀
Replace YOUR_NEW_API_TOKEN below with your own LLM API Gateway access key to run a test immediately.
curl https://api.llm-token.cn/v1/images/generations \
-H "Authorization: Bearer YOUR_NEW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "image-01",
"prompt": "一张可爱的蓝色 AI 小机器人图标,白色背景,极简 3D 风格,居中构图,不要文字",
"response_format": "url",
"n": 1,
"aspect_ratio": "1:1",
"prompt_optimizer": false
}'For your first test, generate just 1 image by setting n: 1. Once you confirm that image generation works, adjust the aspect ratio, style, and quantity as needed.
3. How to Set Request Parameters 🧩
| Parameter | Required | Common Value | Description |
|---|---|---|---|
model | Yes | image-01 | The image generation model name. For more real-time image generation, you can also use image-01-live. |
prompt | Yes | Based on your image requirements | Describes the image you want to generate. Include the subject, style, colors, composition, and intended use. |
response_format | No | url | We recommend url to receive a direct image link. You can also use base64 when your application requires it. |
n | No | 1 | The number of images to generate in one request. Use 1 for routine testing. |
aspect_ratio | No | 1:1 | The image aspect ratio. Common options: 1:1, 16:9, 9:16, 4:3, 3:4, and 21:9. |
prompt_optimizer | No | false | Whether to enable prompt optimization. Use false when you want the model to follow your original prompt more strictly. |
seed | No | Integer | Helps improve reproducibility. Use the same seed when you want similar results across multiple generations. |
width / height | No | Usually unnecessary | aspect_ratio is enough for most use cases. Only send these parameters when you need exact dimensions. |
If the response contains an image URL, save the image promptly. Image links are suitable for temporary previews and downloads, but should not be used as permanent asset URLs.
4. Why Use the LLM API Gateway? 🍬
A typical integration requires switching between multiple model platforms, each with different keys, endpoints, and billing methods. That makes development and maintenance more complicated.
The LLM API Gateway unifies all of these. You only need one LLM API Gateway access key to call image generation through a single endpoint. Usage, multipliers, and balance are all shown in the LLM API Gateway console for clear, centralized management.
| Capability | Description |
|---|---|
| Unified endpoint | All image generation requests use https://api.llm-token.cn/v1/images/generations, simplifying integration. |
| Unified key | Use the new-api-token generated in the LLM API Gateway console instead of switching between multiple platforms. |
| Unified billing | Usage, multipliers, and balance are based on the LLM API Gateway console, making it easier for teams to manage costs. |
| Built for application integration | Suitable for WeChat Official Account illustrations, product images, cover images, automatic agent illustrations, bulk asset generation, and more. |
In short: use one LLM API Gateway access key and one endpoint to add image generation to your product or workflow.
5. How to Use image-01-live ⚡
image-01-live uses the same image generation endpoint. Keep the other parameters unchanged and set model to image-01-live.
{
"model": "image-01-live",
"prompt": "一张赛博风格的蓝色产品宣传图,干净背景,科技感,适合公众号封面",
"response_format": "url",
"n": 1,
"aspect_ratio": "16:9",
"prompt_optimizer": false
}If this model is enabled for your account, you can call it directly this way.
6. Python Example for Your Project 🐍
import requests
url = "https://api.llm-token.cn/v1/images/generations"
headers = {
"Authorization": "Bearer YOUR_NEW_API_TOKEN",
"Content-Type": "application/json",
}
payload = {
"model": "image-01",
"prompt": "一张科技感很强的蓝色应用图标,白色背景,极简 3D 风格,居中构图,不要文字",
"response_format": "url",
"n": 1,
"aspect_ratio": "1:1",
"prompt_optimizer": False,
}
resp = requests.post(url, headers=headers, json=payload, timeout=120)
resp.raise_for_status()
print(resp.json())Image generation takes longer than a typical text response. Set your client timeout to around 120 seconds so the client does not terminate the request before the image is ready.
7. How to Write Better Image Prompts 🪄
For more consistent results, describe your image in this order:
- Subject: What you want to depict, such as “a blue AI robot” or “a World Cup analysis poster.”
- Setting: Where the subject appears, such as “on a white background,” “under stadium lights,” or “on an office desk.”
- Style: Minimalist, photorealistic, 3D, illustration, commercial poster, photographic, and so on.
- Composition: Centered, top-down, half-length, with negative space, landscape cover, and so on.
- Colors: Primary and secondary colors, such as blue and white, black and gold, or contrasting red and blue.
- Constraints: For example, “no text,” “no watermark,” or “clean background.”
You can copy this short template:
一张【比例】的【用途】图片,主体是【主体】,场景是【场景】,整体风格为【风格】,主色为【颜色】,构图【构图要求】,细节要求【限制或补充】。Example:
一张 1:1 的应用图标,主体是蓝色发光的 AI 芯片,白色背景,极简 3D 风格,居中构图,边缘清晰,不要文字。8. Troubleshooting 🛟
| Issue | Solution |
|---|---|
| Authentication failed | Confirm that the request header is written as Authorization: Bearer YOUR_NEW_API_TOKEN and that no extra spaces were copied into the token. |
| Model not found | Confirm that the model name is exactly image-01 or image-01-live, including capitalization. |
| Unexpected image aspect ratio | Adjust aspect_ratio first. Use 16:9 for a typical WeChat Official Account cover or 1:1 for an avatar or icon. |
| Image link does not open | The image URL may have expired. Download the image promptly after generation or save it to your own asset library. |
| Request takes a long time | Image generation requires processing time. Set the request timeout to at least 120 seconds. |
| Results are inconsistent | Make your requirements more specific and remove conflicting descriptions. To get similar results, use a fixed seed. |
9. Version to Share Directly with Developers 📮
We use the LLM API Gateway for image generation through POST https://api.llm-token.cn/v1/images/generations. Set the request header to Authorization: Bearer YOUR_NEW_API_TOKEN. In the request body, use model: image-01 or model: image-01-live, then send parameters such as prompt, response_format: url, n, and aspect_ratio.
10. Common Use Cases 📚
| Use Case | How to Use It |
|---|---|
| WeChat Official Account / Xiaohongshu illustrations | Quickly generate covers, hero images, event posters, and article illustrations. |
| Product and SaaS pages | Generate app icons, feature illustrations, banners, and empty-state illustrations. |
| Ecommerce and product assets | Generate product backgrounds, promotional images, and atmospheric images for product detail pages. |
| Agent automation workflows | Let agents automatically generate relevant illustrations to improve content production efficiency. |