IMG
Image Generation API
Access top image generation models through a unified API -- text-to-image, image editing, mask inpainting, and multi-image fusion.
Quick Start
1
Get your API key from Console2
Choose an image provider below3
POST to create a generation task4
Poll GET to retrieve the image URLAuthentication
Add Authorization header to all requests:
Authorization: Bearer YOUR_API_KEY
Endpoints
POST
/api/v1/images/generationsCreate an image generation task
GET
/api/v1/images/generations?task_id=xxxQuery task status and get image URL
API Reference
Select a provider to see its parameters and examples
SparkPix
SparkPix
SparkPix's ultra-fast image models with two separate endpoints. SparkPix Image generates text-to-image in under 1 second with LoRA custom style support. SparkPix Image Edit supports multi-image reference editing. Both are synchronous APIs returning results directly.
Models
SparkPix Image
POST /api/v1/images/generations-sync$0.0100/image
Text-to-image, sync, <1s, LoRA support
SparkPix Image Edit
POST /api/v1/images/edit$0.0130/image
Multi-image editing, sync, <1s
Parameters
── SparkPix Image params ──
POST /api/v1/images/generations-syncpromptrequired
stringText description for image generationaspect_ratio
string"custom" (default, auto size), "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"width
integerOnly when aspect_ratio="custom", 256-1440, must be multiple of 16height
integerOnly when aspect_ratio="custom", 256-1440, must be multiple of 16prompt_upsampling
booleanAuto-enhance prompt with LLM (default: false)seed
integerRandom seed for reproducibilitylora_weights
stringHuggingFace LoRA weights URL, format: huggingface.co/<owner>/<model>[/<file.safetensors>]lora_scale
numberLoRA strength, -1 to 3, default 0.5callBackUrl
stringWebhook URL called when task completes── SparkPix Image Edit params ──
POST /api/v1/images/editpromptrequired
stringEditing instructions. Refer to inputs as "image 1", "image 2", etc.images
string[]Reference image URL array, first image is the primary oneaspect_ratio
string"match_input_image" (default, match first image), "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"turbo
booleanTurbo mode (default: true), recommended off for complex tasksseed
integerRandom seed for reproducibilitycallBackUrl
stringWebhook URL called when task completesNotes
- -The two models use different API endpoints
- -SparkPix Image (text-to-image): POST /api/v1/images/generations-sync
- -SparkPix Image Edit (image editing): POST /api/v1/images/edit
- -Both are synchronous APIs returning image URLs directly, no polling needed
- -Response format: { code: 200, data: { url, model, credits, duration } }
- -SparkPix Image aspect_ratio defaults to "custom" (auto), SparkPix Image Edit defaults to "match_input_image"
Code Example
# SparkPix Image: Text-to-image (sync, sub-1-second)
curl -X POST https://apimodels.app/api/v1/images/generations-sync \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cute cat wearing a space helmet, digital art",
"aspect_ratio": "16:9",
"seed": 42
}'
# SparkPix Image Edit: Multi-image editing (sync)
curl -X POST https://apimodels.app/api/v1/images/edit \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Make the background a sunset beach",
"images": ["https://example.com/photo.jpg"],
"aspect_ratio": "16:9"
}'Response Format
Create Task Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending"
}
}Success Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"resultUrls": ["https://r2.apimodels.app/images/xxx.jpeg"],
"createTime": 1705123450000,
"completeTime": 1705123465000
}
}Failed Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"failMsg": "Content policy violation"
}
}Task States
pendingQueued, waiting to startprocessingImage is being generatedcompletedDone -- image URLs availablefailedGeneration failedError Codes
400Bad Request -- invalid or missing parameters401Unauthorized -- invalid API key402Payment Required -- insufficient credits404Not Found -- task ID not found500Internal Server ErrorImportant Notes
- -Image files are stored for 7 days -- download promptly
- -Failed generations are not charged
- -Poll every 2-3 seconds for status updates
- -Use callback_url for production workloads to avoid polling
- -Keep your API key secure