Image Endpoints
POST /api/v1/studio/image/generate
Generate images from a text prompt using various AI models.
Request Body
promptstringrequiredImage description (3–2000 characters).
modelstringModel ID. One of: nano-banana (default), nano-banana-pro, seedream, gpt-image, gpt-image-mini, gpt-image-2, gemini-imagen, imagen-ultra, grok-imagine.
numImagesnumberNumber of images to generate (1–10, varies by model).
aspectRatiostringAspect ratio (e.g. "16:9", "1:1"). Varies by model.
outputFormatstringOutput format: jpeg, png, or webp.
resolutionstringResolution: 1K, 2K, or 4K (nano-banana-pro only).
widthnumberWidth in pixels (1024–4096, seedream only).
heightnumberHeight in pixels (1024–4096, seedream only).
seednumberSeed for reproducibility (0–2147483647).
negativePromptstringNegative prompt (imagen-ultra only).
qualitystringQuality: auto, low, medium, high (gpt-image, gpt-image-2).
backgroundstringBackground: auto, transparent, opaque (gpt-image only).
imageSizestring | objectFor gpt-image-2: square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3 (default), landscape_16_9, or a custom { width, height } object (multiples of 16).
Example
curl -X POST https://terramind.com/api/v1/studio/image/generate \
-H "Authorization: Bearer sk-tm-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene sunset over mountains",
"model": "nano-banana",
"numImages": 1,
"aspectRatio": "16:9"
}'Response
{
"success": true,
"data": {
"model": "nano-banana",
"images": [
{
"url": "https://storage.googleapis.com/...",
"contentType": "image/jpeg",
"width": 1024,
"height": 576
}
],
"metadata": {
"outputImages": 1,
"prompt": "A serene sunset over mountains",
"aspectRatio": "16:9"
}
},
"credits": { "used": 1, "cost": 5.0, "remaining": 9995.0 }
}Billing & Credit Reservation
Credits are reserved up-front before the job starts and charged only on success. If the generation fails (provider error, invalid input, storage failure) the reservation is released and your balance is untouched. When a model is queued asynchronously (async: true or returns HTTP 202), the reservation is settled by the fal webhook — success charges, failure releases. Insufficient balance returns 402 INSUFFICIENT_CREDITS; hitting the 6-hour usage window returns 429 WINDOW_EXHAUSTED with a resetAt timestamp. See Credit Reservation for details.
POST /api/v1/studio/image/edit
Edit existing images using text instructions and reference image URLs.
Request Body
promptstringrequiredEdit instructions (3–2000 characters).
imageUrlsstring[]requiredArray of image URLs to edit (1–10).
modelstringModel: nano-banana (default), seedream, or gpt-image-2.
numImagesnumberNumber of output images.
outputFormatstringOutput format: jpeg, png, or webp.
seednumberSeed for reproducibility.
Example
curl -X POST https://terramind.com/api/v1/studio/image/edit \
-H "Authorization: Bearer sk-tm-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Make the sky more dramatic with storm clouds",
"imageUrls": ["https://example.com/photo.jpg"],
"model": "nano-banana"
}'POST /api/v1/studio/image/upscale
Upscale an image by 2x, 4x, or 6x. Accepts application/json with an imageUrl. Returns a JSON payload with the hosted upscaled image URL.
Body
imageUrlstringrequiredThe URL of the image to upscale.
scaleFactornumberScale factor: 2 (default), 4, or 6.
servicestringService: fal (default) or clipdrop.
modelstringModel (fal only): Standard V2, High Fidelity V2, CGI, Low Resolution V2.
faceEnhancementbooleanEnable face enhancement (fal only, default: true).
persistToStoragebooleanStore the result and return a hosted URL (default: false).
Example
curl -X POST https://terramind.com/api/v1/studio/image/upscale \
-H "Authorization: Bearer sk-tm-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/photo.png",
"scaleFactor": 4,
"persistToStorage": true
}'POST /api/v1/studio/image/remove-background
Remove the background from an image. Accepts application/json with an imageUrl. Returns a JSON payload with the hosted result URL.
Body
imageUrlstringrequiredThe URL of the image.
modelstringModel: General Use (Light) (default), General Use (Heavy), or Portrait.
operatingResolutionstringResolution: 1024x1024 (default), 2048x2048, or 2304x2304.
refineForegroundbooleanRefine foreground edges (default: true).
persistToStoragebooleanStore the result and return a hosted URL (default: false).
Example
curl -X POST https://terramind.com/api/v1/studio/image/remove-background \
-H "Authorization: Bearer sk-tm-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/photo.png",
"model": "Portrait",
"persistToStorage": true
}'POST /api/v1/studio/image/batch
Batch process multiple images with a single operation. Takes a JSON body with an array of image URLs. For local files, upload each first via POST /api/v1/storage/upload-url and pass the returned fileUrls.
Request Body
operationstringrequiredOperation: remove-background or upscale.
imageUrlsstring[]requiredArray of image URLs to process (1–10).
scaleFactornumberScale factor for upscale operation (default: 2).
servicestringService for upscale (fal default, or clipdrop).
Example
curl -X POST https://terramind.com/api/v1/studio/image/batch \
-H "Authorization: Bearer sk-tm-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"operation": "upscale",
"imageUrls": [
"https://example.com/a.png",
"https://example.com/b.png"
],
"scaleFactor": 2
}'Response
{
"success": true,
"data": {
"total": 2,
"successful": 2,
"failed": 0,
"results": [
{ "success": true, "index": 0, "data": "https://fal.ai/up-0.png" },
{ "success": true, "index": 1, "data": "https://fal.ai/up-1.png" }
]
},
"credits": { "used": 1, "cost": 10.0, "remaining": 9990.0 }
}