Beta

This API is in beta. Endpoints, request/response formats, and behavior may change without notice.

API Reference

Terramind Documentation

Image Endpoints

POST /api/v1/studio/image/generate

Generate images from a text prompt using various AI models.

Request Body

promptstringrequired

Image description (3–2000 characters).

modelstring

Model ID. One of: nano-banana (default), nano-banana-pro, seedream-5.5, seedream-5-pro, seedream-5-lite, gpt-image, gpt-image-mini, gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, gpt-image-2.6-sunburst, gemini-imagen, imagen-ultra, grok-imagine.

numImagesnumber

Number of images to generate (1–10, varies by model).

aspectRatiostring

Aspect ratio (e.g. "16:9", "1:1"). Varies by model.

outputFormatstring

Output format: jpeg, png, or webp; gif for an animation (gpt-image-2.6).

frameCountnumber

GIF only: 2–16 frames, default 9. Frames render on one sheet of at most 3840 px on an edge and 8,294,400 pixels, so imageSize is each frame's: 1024×768 fits up to 9 frames, square (512×512) fits 16, and square_hd fits no GIF.

frameDurationMsnumber

GIF only: 20–2000 ms per frame, default 200.

resolutionstring

Resolution tier, per model (see params.resolutions in the catalog): 1K, 2K or 4K for Nano Banana; 1.5K or 2K (default) for seedream-5.5 and seedream-5-pro; 2K (default) or 3K for seedream-5-lite. Seedream renders each tier at fixed sizes per aspectRatio (21:9 to 9:16; Pro's 1.5K has no 3:2, 2:3 or 21:9) and outputs jpeg or png.

seednumber

Seed for reproducibility (0–2147483647).

negativePromptstring

Negative prompt (imagen-ultra only).

qualitystring

Quality: auto, low, medium, high (gpt-image, gpt-image-2, gpt-image-2.5, gpt-image-2.6).

backgroundstring

Background: auto, transparent, opaque (gpt-image, gpt-image-2, gpt-image-2.5, gpt-image-2.6).

imageSizestring | object

For gpt-image-2, gpt-image-2.5 and gpt-image-2.6: 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
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

JSON
{
  "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. A model may run on more than one provider (fal, Atlas Cloud, the Vercel AI Gateway): a blocking call runs on the cheapest that can serve it and falls back to the next if it fails, the reservation is held at the dearest and the charge is the list price × 1.28 of the provider that ran, named in data.provider. Seedream 5.0 runs on all three (Pro edits on fal and Atlas Cloud); Seedream 5.5 runs on Atlas Cloud only, so its edits need a named aspectRatio. An edit with aspectRatio: auto, which follows the input's shape, runs on fal. Add transport ("fal", "atlas" or "gateway") to run on that provider only, with no fallback, charged at its list price × 1.28; a provider that cannot serve the request is a 400 INVALID_INPUT naming why, one that is unavailable a 409 TRANSPORT_UNAVAILABLE (queued async image jobs run on fal only). 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

promptstringrequired

Edit instructions (3–2000 characters).

imageUrlsstring[]required

Array of image URLs to edit (1–10).

modelstring

Model: nano-banana (default), seedream-5.5 (up to 10 images; name an aspectRatio), seedream-5-pro (up to 10 images), seedream-5-lite (up to 14), gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, or gpt-image-2.6-sunburst.

numImagesnumber

Number of output images.

outputFormatstring

Output format: jpeg, png, or webp; gif for an animation (gpt-image-2.6).

frameCountnumber

GIF only: 2–16 frames, default 9. Frames render on one sheet of at most 3840 px on an edge and 8,294,400 pixels, so imageSize is each frame's: 1024×768 fits up to 9 frames, square (512×512) fits 16, and square_hd fits no GIF.

frameDurationMsnumber

GIF only: 20–2000 ms per frame, default 200.

seednumber

Seed for reproducibility.

qualitystring

Quality: low, medium, high (gpt-image-2, gpt-image-2.5, gpt-image-2.6).

backgroundstring

Background: auto, transparent, opaque (gpt-image-2, gpt-image-2.5, gpt-image-2.6).

maskUrlstring

Mask image URL for inpainting; white regions are the edit areas (gpt-image-2, gpt-image-2.5, gpt-image-2.6).

Example

curl
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

imageUrlstringrequired

The URL of the image to upscale.

scaleFactornumber

Scale factor: 2 (default), 4, or 6.

servicestring

Service: fal (default) or clipdrop.

modelstring

Model (fal only): Standard V2, High Fidelity V2, CGI, Low Resolution V2.

faceEnhancementboolean

Enable face enhancement (fal only, default: true).

persistToStorageboolean

Store the result and return a hosted URL (default: false).

Example

curl
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

imageUrlstringrequired

The URL of the image.

modelstring

Model: General Use (Light) (default), General Use (Heavy), or Portrait.

operatingResolutionstring

Resolution: 1024x1024 (default), 2048x2048, or 2304x2304.

refineForegroundboolean

Refine foreground edges (default: true).

persistToStorageboolean

Store the result and return a hosted URL (default: false).

Example

curl
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

operationstringrequired

Operation: remove-background or upscale.

imageUrlsstring[]required

Array of image URLs to process (1–10).

scaleFactornumber

Scale factor for upscale operation (default: 2).

servicestring

Service for upscale (fal default, or clipdrop).

Example

curl
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

JSON
{
  "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 }
}