Generate images from text prompts with GPT Image2 through BetterToken’s OpenAI-compatible API.
Documentation Index
Fetch the complete documentation index at: https://docs.bettertoken.ai/llms.txt
Use this file to discover all available pages before exploring further.
POST /v1/images/generations
The text-to-image endpoint uses an application/json request body. Submit a prompt, keep the HTTP request open, and read the generated image from data[0].b64_json in the same response.
https://www.bettertoken.ai/v1 as the Base URL. Pass your BetterToken API Key through Authorization: Bearer YOUR_API_KEY.n > 1.
size | Ratio | Use case |
|---|---|---|
auto | Auto | Automatic size selection |
1024x1024 | 1:1 | Square images, avatars, covers, assets |
1536x1024 | 3:2 | Landscape posters, banners, scenes |
1024x1536 | 2:3 | Portrait mobile covers and posters |
2048x2048 | 1:1 | High-resolution square images |
2048x1152 | 16:9 | High-resolution landscape images |
3840x2160 | 16:9 | 4K landscape images |
2160x3840 | 9:16 | 4K portrait images |
size represents the expected aspect ratio and size tier. The actual returned pixels may be mapped or adjusted by the server. Use the decoded image dimensions instead of forcibly cropping the output to the requested value.
data[0].b64_json and save it as base64 image content. The response may include extra fields such as revised_prompt; allow these fields in your client.
Always set output_format: "png". Then save the decoded image as .png without inspecting file headers.
POST /images/generations, keep the current HTTP request open until the server responds. When generation succeeds, the image content is returned in data[0].b64_json.
The endpoint does not return a task_id, and there is no separate status query or result download endpoint.
408, 409, 425, 429, and 5xx.400, 401, missing parameters, or malformed requests automatically.3s, 8s, and 15s.Use your BetterToken API Key as a bearer token. Do not expose API keys in frontend browser code, screenshots, logs, tickets, or Git repositories.
固定使用 gpt-image-2。
gpt-image-2 "gpt-image-2"
图片生成提示词。
"一张未来感 AI 产品海报,浅色背景,玻璃质感,干净构图,高级科技感"
推荐固定为 1。多张图片建议发起多次独立请求。
1 <= x <= 11
图片尺寸和比例档位。auto 为自动;1024x1024 和 2048x2048 为 1:1;1536x1024 为 3:2;1024x1536 为 2:3;2048x1152 和 3840x2160 为 16:9;2160x3840 为 9:16。实际返回像素可能由服务端映射或调整,客户端应以解码后的真实图片尺寸为准。
auto, 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, 2160x3840 "1024x1024"
推荐固定为 b64_json,便于稳定保存图片。
b64_json "b64_json"
推荐固定为 png。不要依赖 jpeg 或 webp 直接返回对应格式。
png "png"