通过统一的接口调用多家顶级图片生成模型,支持文生图、图片编辑、蒙版修复和多图融合。
所有请求需在 Header 中携带 Bearer Token:
Authorization: Bearer YOUR_API_KEY
/api/v1/images/generations创建图片生成任务
/api/v1/images/generations?task_id=xxx查询任务状态并获取图片链接
选择模型提供商查看对应的参数和示例
xAI 出品的图片生成模型,支持文生图、URL 图片编辑、蒙版修复(精确替换图片指定区域)。
grok-image/grok-4.2-imagegrok-imagine/grok-imagine-imagegrok-imagine-pro/grok-imagine-image-pro# Step 1: Create task (text-to-image)
curl -X POST https://apimodels.app/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-image/grok-4.2-image",
"prompt": "A cute cat wearing a space helmet, digital art",
"size": "1024x1024",
"n": 1
}'
# Mask inpainting (base64 image + mask)
curl -X POST https://apimodels.app/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-image/grok-4.2-image",
"prompt": "Replace with a golden retriever",
"image": "BASE64_ENCODED_IMAGE",
"mask": "BASE64_ENCODED_MASK",
"size": "1024x1024"
}'
# Step 2: Poll status
curl "https://apimodels.app/api/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending"
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"resultUrls": ["https://r2.apimodels.app/images/xxx.jpeg"],
"createTime": 1705123450000,
"completeTime": 1705123465000
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"failMsg": "Content policy violation"
}
}在创建请求中传入 callback_url 后,任务进入 completed 或 failed 终态时,我们会向该地址发起一次 HTTP POST。请求头仅包含 Content-Type: application/json,无签名头。失败会自动重试 3 次(指数退避 1s/2s/4s,单次超时 10s);如果仍未成功,后台会在 30 分钟内继续补偿重发,直到接收端返回 2xx。
POST {your callback_url}
Content-Type: application/json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"model": "<provider>/<model_name>",
"state": "completed" | "failed",
"param": "<JSON string>", // request params, JSON.parse once
"resultJson": "<JSON string> | null", // result object, JSON.parse once
"failCode": null | "CONTENT_MODERATION | INVALID_INPUT | INSUFFICIENT_BALANCE | UPSTREAM_BUSY | UPSTREAM_FAILED | TIMEOUT | INTERNAL_ERROR | OTHER",
"failMsg": null | "string",
"retryable": true | false, // present when state=failed: safe to retry/fallback
"costTime": 12345, // duration in ms
"completeTime": 1705123465000, // ms epoch
"createTime": 1705123450000 // ms epoch
}
}注意:data.param 与 data.resultJson 都是 JSON 字符串,使用前必须 JSON.parse 一次才能拿到对象。
{
"resultUrls": [
"https://r2.apimodels.app/images/xxx.png"
]
}resultUrls 为已上传至 Cloudflare R2 的图片 URL 数组。多图模型(如 SparkPix Image Edit、n>1 的 GPT Image 2 Lite)会返回多个;state=failed 时通常为 null 或 {"resultUrls":[]},请不要假设一定有链接。
app.post('/webhook/image', express.json(), (req, res) => {
const { taskId, state, param, resultJson, failMsg } = req.body.data
if (state === 'completed') {
const { resultUrls } = JSON.parse(resultJson)
console.log('image ready', taskId, resultUrls[0])
} else {
console.warn('image failed', taskId, failMsg)
}
res.status(200).end() // must be 2xx, otherwise we retry
})pending任务已排队,等待处理processing图片生成中completed生成成功,可获取图片链接failed生成失败400请求参数错误或缺失401API 密钥无效402积分不足404任务 ID 不存在500服务器内部错误下列所有模型通过统一 API、一个 key 即可调用。点击模型查看完整 playground 与文档。
| 模型 | model 参数 | 价格 | 说明 |
|---|---|---|---|
| GPT Image 2 Lite | gpt-image-2-lite | $0.015 | The cheapest, fastest gpt-image-2 channel — 1K-only at a flat $0.015/image. Built for person editing & generation and light-text tutorial/diagram images. Not for 2K/4K HD or text-heavy full-screen layouts (use gpt-image-2 for those). |
| GPT Image 2 | gpt-image-2 | $0.025+ | OpenAI gpt-image-2. Text-to-image and multi-image editing (up to 16 reference images), aspect-ratio control, native 1K / 2K / 4K — $0.025 / $0.04 / $0.06 per image. |
| GPT Image 2 All | gpt-image-2-all | $0.005+ | OpenAI gpt-image-2, OpenAI-compatible sync API — drop-in for Codex / Cursor / the OpenAI SDK. Full 1K / 2K / 4K × low / medium / high quality, text-to-image and multi-image editing, priced per resolution × quality from $0.005. |
| Nanobananapro-gemini | nanobananapro-gemini | $0.025 | Gemini 3 Pro Image via a budget channel. Professional asset creation with advanced reasoning and high-fidelity text rendering. |
| Nanobanana2-gemini | nanobanana2-gemini | $0.025 | Gemini 3.1 Flash Image via a budget channel. High-performance image generation optimized for speed and high-volume use. |
| SparkPix Image | sparkpix-image | $0.01 | Sub 1 second text-to-image model built for production use cases. State-of-the-art speed, quality, and text rendering. |
| SparkPix Image Edit | sparkpix-image-edit | $0.013 | Sub 1 second multi-image editing model. Fast, affordable AI image editing with precise prompt adherence and multi-image support. |
| Nanobanana-2-beta | nanobanana-2-beta | $0.05+ | Budget-friendly Gemini 3.1 Flash image generation. Text-to-image and image editing — 1K/2K $0.05, 4K $0.08 per image. |
| Kling V3 Image | kling-v3-image | $0.05 | Kling V3 image generation. Text-to-image and single-reference image-to-image, 1K/2K resolution. $0.05 per image. |
| Kling V3 Omni | kling-v2-new | $0.05+ | Kling V3 Omni image generation. Multi-image reference & fusion, element consistency, single/series output, 1K/2K/4K — 1K/2K $0.05, 4K $0.10 per image. |
| Kling Omni-Image | kling-image-o1 | $0.05 | AI image generation and editing by Kling (omni-image, model kling-image-o1). Supports 1K/2K resolution and multi-image input. $0.05 per image. |
| Doubao Seedream 5.0 Lite (Official) | doubao-seedream-5-0-260128 | $0.055 | Doubao Seedream 5.0 Lite via ByteDance Volcano Ark official API. Unified text-to-image and image-to-image (pass image for I2I, omit for T2I). 2K / 4K output, no watermark, PNG. |
| Doubao Seedream 4.5 | doubao-seedream-4-5-251128 | $0.05 | High quality Doubao Seedream 4.5 image generation. Supports text-to-image and image editing with 2K/4K resolution. |
| Grok 4.2 Image | grok-4.2-image | $0.025 | Image generation and editing powered by Grok 4.2. Supports text-to-image creation and image editing with mask inpainting. |
| Grok Imagine Image | grok-imagine-image | $0.025 | Multimodal AI image generation by X platform. Generates high-quality images from text descriptions. |
| Grok Imagine Image Pro | grok-imagine-image-pro | $0.10 | Upgraded multimodal AI model by X platform with stronger understanding and finer detail generation for higher precision images. |
| Nanobanana2 | nanobanana2 | $0.05+ | Fast image generation powered by Gemini 3.1 Flash. Supports text-to-image and image editing — 1K/2K $0.05, 4K $0.08 per image. |
| gemini-3.1-flash-image | gemini-3.1-flash-image | $0.04+ | Google's gemini-3.1-flash-image (GA release). High-quality image generation and conversational editing at low latency. Priced by resolution: 512 $0.04, 1K/2K $0.06, 4K $0.10. |
| gemini-3-pro-image | gemini-3-pro-image | $0.10+ | Google's gemini-3-pro-image (GA release). Top-quality, high-fidelity image generation and editing with advanced reasoning. Priced by resolution: 1K/2K $0.10 (25% cheaper than official), 4K $0.15 (37.5% cheaper than official). |
| Nanobanana-2-lite | nanobanana-2-lite | $0.04+ | Budget-friendly image editing powered by Gemini 3.1 Flash. Image-to-image only — 1K/2K $0.04, 4K $0.07 per image. |
| Gemini 3 Pro Image (Pro) | nanobananapro | $0.06+ | Premium image generation powered by Gemini 3 Pro. 99% success rate. Best quality and reliability. |
| Gemini 3 Pro Image (Lite) | nanobananapro-lite | $0.06+ | High quality image generation powered by Gemini 3 Pro. 97% success rate. Supports text-to-image and image editing. |
| Gemini 2.5 Flash Image | nanobanana-lite-gemini-2.5-flash-image | $0.0295 | Fast image generation powered by Gemini 2.5 Flash. Supports text-to-image and image editing with natural language. |