Skip to content
Documentation navigation
On this page

API reference

Parameters, examples, and responses for generations and assets.

Create a generation

POST /v2/generations · Content-Type: application/json

FieldTypeRules
modelstringRequired. An enabled model, such as magi-2.
partsarrayRequired, 1–21 items. Include exactly one nonblank text item of up to 15,000 Unicode code points, plus any media references in input order.
durationintegerRequired. Output duration in whole positive seconds.
aspectRatiostringRequired. Use width:height with 1–5 digits per side and no leading zeros, e.g. 16:9.
resolutionstringOnly 1080p is supported. Defaults to 1080p when omitted, null, empty or whitespace-only. The model must support the combination of ratio, resolution, duration and input mode.
enhancePromptbooleanOptional. Enables prompt enhancement when true and disables it when false. If omitted, uses the model’s default configuration.
generateAudiobooleanDefaults to true. Audio references are accepted even when set to false.
seedintegerOmit or pass -1 to select a random positive seed. A value from 0 to 4294967295, inclusive, fixes the seed.

Omit unset optional fields. Only resolution accepts explicit null. Use native JSON numbers and booleans and supply each documented key at most once. Omit watermark on this endpoint, including false.

parts[] structure

Each item is an object. Its type selects the required sibling field. The native API does not accept role. To specify a first or last frame, see Volcengine Ark compatibility.

typeRequired fieldExample itemPer generation
texttext (string){"type":"text","text":"Move the camera slowly forward."}Exactly one, at any position
reference_imageimage (object){"type":"reference_image","image":{"assetId":"101"}}Up to 10 images
reference_videovideo (object){"type":"reference_video","video":{"assetId":"102"}}Up to 5 videos, 2–30 s each, ≤ 30 s combined
reference_audioaudio (object){"type":"reference_audio","audio":{"url":"https://media.example.com/sound.mp3"}}Up to 5 audio clips, ≤ 30 s combined

Set exactly one of assetId or url in each image, video or audio object. Media references retain their array order. See Upload an asset for supported formats and file sizes.

SourceTypeValue
assetIdstringUpload the matching media type with POST /v1/assets using a key from the same organization. Convert the returned numeric id to its exact decimal string. Use a positive int64 with no leading zeros.
url (HTTPS)stringA public HTTPS download URL of up to 8,192 characters. Signed query parameters are allowed. The download must work without cookies or extra headers. Omit user credentials and URL fragments.
url (uploaded asset)stringUse asset://<id> for an image, video or audio file uploaded by the same organization. The ID follows the same rules as assetId. For example, {"type":"reference_image","image":{"url":"asset://101"}}.

Example request

Replace 123456789 with the image ID returned by POST /v1/assets, preserving its full decimal precision.

bash
curl "https://api.sand.ai/v2/generations" \
  -H "Authorization: Bearer $SAND_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary '{
  "model": "magi-2",
  "parts": [
    {
      "type": "text",
      "text": "A slow camera push toward waves breaking against the rocks."
    },
    {
      "type": "reference_image",
      "image": {
        "assetId": "123456789"
      }
    }
  ],
  "duration": 5,
  "aspectRatio": "16:9",
  "resolution": "1080p"
}'

Response

202 Accepted · Location: /v2/generations/987654321

json
{
  "id": "987654321"
}

Save the string id for polling. Creation is not idempotent. Resubmitting after a timeout or lost response may create a second billable task. If an error contains details.generation_id, retrieve that ID first.

Invalid parameters return HTTP 400 with invalid_parameter. Keys in details identify the failing field, such as parts[1].role or parts[1].image.assetId.

Retrieve a Generation

Retrieve the status and result of a generation in the current organization. Requires Bearer authentication.

http
GET /v2/generations/{id}

Path parameters

ParameterTypeRequiredDescription
idstringYesID returned when creating the generation. A positive int64 represented as a decimal string, with no leading zeros.

Example request

Set SAND_GENERATION_ID to the saved generation ID. Use the same ID if polling is interrupted.

bash
export SAND_GENERATION_ID='123456789'
curl "https://api.sand.ai/v2/generations/$SAND_GENERATION_ID" \
  -H "Authorization: Bearer $SAND_API_KEY"

Response

A successful retrieval returns HTTP 200 OK and Cache-Control: no-store. Check status for the generation outcome.

json
{
  "id": "123456789",
  "status": "succeeded",
  "output": {
    "videoUrl": "https://files.example.com/video.mp4?signature=example",
    "urlExpiresAt": "2026-11-02T03:00:00.000Z"
  },
  "error": null,
  "createdAt": "2026-11-02T01:55:00.000Z"
}

All five top-level fields are always present. Timestamps use RFC 3339 in UTC with millisecond precision.

FieldTypeDescription
idstringGeneration ID.
statusstringGeneration status, listed below.
outputobject | nullResult object on success; otherwise null.
output.videoUrlstring | nullVideo download URL.
output.urlExpiresAtstring | nullDownload URL expiration time.
errorobject | nullFailure information when failed; otherwise null.
error.codestringFailure code. See Generation Failures.
error.messagestringFailure description.
createdAtstringGeneration creation time.

Statuses

StatusMeaningAction
queuedWaiting to run.Continue polling.
processingPreparing, generating, or undergoing moderation.Continue polling.
succeededGeneration completed.Check the download URL and retrieve the video.
failedGeneration or moderation failed.Stop polling and check error.
canceledGeneration was canceled.Stop polling.

Poll one generation every 10 seconds. For multiple generations, stagger requests and increase the interval to stay within the organization’s read quota. See Rate limits, polling and retries.

Download the video

Check that output and output.videoUrl are not null before downloading. The download does not require an API key. URLs are valid for 60 minutes; use urlExpiresAt for the exact expiration. Retrieve the generation again to obtain a fresh URL.

If the output of a successful task is unavailable, its URL fields may be null. Later moderation decisions can affect access; use the latest retrieval response.

If the generation is missing, deleted, or belongs to another organization, the endpoint returns 404 generation_not_found. See Errors for other request failures.

The owning organization can retrieve the task by ID during its retention period even after model access is revoked.

Upload an asset

POST /v1/assets · multipart/form-data

Upload a single file using an organization API key, then reference it in a native v2 or Ark generation.

Request parameters

FieldTypeRequiredDescription
filebinaryYesOne file with a supported filename extension.

Use cURL -F or the client’s FormData to generate the multipart boundary. The complete multipart request is limited to 201,048,576 bytes.

Example request

bash
curl "https://api.sand.ai/v1/assets" \
  -H "Authorization: Bearer $SAND_API_KEY" \
  -F "file=@./reference.png"

Response

200 OK

json
{ "id": 123456789 }

The response id is a JSON number (int64). In JavaScript, use a lossless JSON parser before converting the ID to a decimal string.

InterfaceImage reference
v2 · assetId{"type":"reference_image","image":{"assetId":"123456789"}}
v2 · url{"type":"reference_image","image":{"url":"asset://123456789"}}
Ark{"type":"image_url","role":"reference_image","image_url":{"url":"asset://123456789"}}

Media limits

TypeFormatsPer filePer task
ImageJPEG / PNG / WebP / BMP / TIFF / GIF / HEIC / HEIFUnder 30,000,000 bytesUp to 10
VideoMP4 / MOV (H.264 / H.265)≤ 200,000,000 bytes, 2–30 sUp to 5, ≤ 30 s total
AudioWAV / MP3≤ 15,000,000 bytes, 2–30 sUp to 5, ≤ 30 s total

Duration bounds are inclusive. Count each occurrence of a repeated reference. The audio total counts standalone audio files only. Decoding and content checks may still fail after generation is accepted.

Uploaded images must be 16–10,000 pixels per side, at most 16,000,000 pixels in total, with the longer side at most 100 times the shorter side. Reference videos may omit audio. MP4 supports embedded AAC or MP3. MOV also supports PCM.

Upload errors

The following errors return HTTP 400. Preserve the leading zeros in the string code.

CodeCause
00003Missing multipart boundary or file, wrong file field, no filename extension, or multiple files.
00200Unsupported file extension.
00202Invalid file content, image dimensions or media duration.
00204File or complete request exceeds its byte limit.

Retrieve an Asset

Get a file URL for an asset in the current organization. Requires Bearer authentication.

http
GET /v1/assets/{id}

Path parameters

ParameterTypeRequiredDescription
idinteger (int64)YesAsset ID returned by the upload endpoint.

Example request

Replace 123456789 with the asset ID.

bash
curl https://api.sand.ai/v1/assets/123456789 \
  -H "Authorization: Bearer $SAND_API_KEY"

Response

A successful request returns HTTP 200 OK.

json
{
  "id": 123456789,
  "url": "https://files.example.com/start-frame.png?signature=example"
}
FieldTypeDescription
idinteger (int64)Asset ID.
urlstringFile URL, or an empty string "" if no URL is currently available.

Signed URLs are valid for 60 minutes. Retrieve the asset again after expiration to obtain a fresh URL. Check that url is not empty before downloading. The download does not require an API key.

A missing or deleted asset returns 404; an asset belonging to another organization returns 403. See Asset Errors for error codes.

Delete an Asset

Delete an asset in the current organization. Requires Bearer authentication.

http
DELETE /v1/assets/{id}

Path parameters

ParameterTypeRequiredDescription
idinteger (int64)YesID of the asset to delete.

No request body is required.

Example request

Replace 123456789 with the asset ID.

bash
curl -X DELETE https://api.sand.ai/v1/assets/123456789 \
  -H "Authorization: Bearer $SAND_API_KEY"

Response

A successful deletion returns HTTP 200 OK.

json
{ "id": 123456789 }
FieldTypeDescription
idinteger (int64)ID of the deleted asset.

A deleted asset cannot be retrieved or used in new generation requests. Retrieving or deleting it again returns 404. Deleting an asset does not cancel generations, and previously issued URLs may remain valid. Wait for related generations to finish before deleting input assets.

Accessing another organization's asset returns 403. See Asset Errors for error codes.