API reference
Parameters, examples, and responses for generations and assets.
Create a generation
POST /v2/generations · Content-Type: application/json
| Field | Type | Rules |
|---|---|---|
model | string | Required. An enabled model, such as magi-2. |
parts | array | Required, 1–21 items. Include exactly one nonblank text item of up to 15,000 Unicode code points, plus any media references in input order. |
duration | integer | Required. Output duration in whole positive seconds. |
aspectRatio | string | Required. Use width:height with 1–5 digits per side and no leading zeros, e.g. 16:9. |
resolution | string | Only 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. |
enhancePrompt | boolean | Optional. Enables prompt enhancement when true and disables it when false. If omitted, uses the model’s default configuration. |
generateAudio | boolean | Defaults to true. Audio references are accepted even when set to false. |
seed | integer | Omit 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.
type | Required field | Example item | Per generation |
|---|---|---|---|
text | text (string) | {"type":"text","text":"Move the camera slowly forward."} | Exactly one, at any position |
reference_image | image (object) | {"type":"reference_image","image":{"assetId":"101"}} | Up to 10 images |
reference_video | video (object) | {"type":"reference_video","video":{"assetId":"102"}} | Up to 5 videos, 2–30 s each, ≤ 30 s combined |
reference_audio | audio (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.
| Source | Type | Value |
|---|---|---|
assetId | string | Upload 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) | string | A 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) | string | Use 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.
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
{
"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.
GET /v2/generations/{id}
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | ID 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.
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.
{
"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.
| Field | Type | Description |
|---|---|---|
id | string | Generation ID. |
status | string | Generation status, listed below. |
output | object | null | Result object on success; otherwise null. |
output.videoUrl | string | null | Video download URL. |
output.urlExpiresAt | string | null | Download URL expiration time. |
error | object | null | Failure information when failed; otherwise null. |
error.code | string | Failure code. See Generation Failures. |
error.message | string | Failure description. |
createdAt | string | Generation creation time. |
Statuses
| Status | Meaning | Action |
|---|---|---|
queued | Waiting to run. | Continue polling. |
processing | Preparing, generating, or undergoing moderation. | Continue polling. |
succeeded | Generation completed. | Check the download URL and retrieve the video. |
failed | Generation or moderation failed. | Stop polling and check error. |
canceled | Generation 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
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | One 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
curl "https://api.sand.ai/v1/assets" \
-H "Authorization: Bearer $SAND_API_KEY" \
-F "file=@./reference.png"
Response
200 OK
{ "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.
| Interface | Image 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
| Type | Formats | Per file | Per task |
|---|---|---|---|
| Image | JPEG / PNG / WebP / BMP / TIFF / GIF / HEIC / HEIF | Under 30,000,000 bytes | Up to 10 |
| Video | MP4 / MOV (H.264 / H.265) | ≤ 200,000,000 bytes, 2–30 s | Up to 5, ≤ 30 s total |
| Audio | WAV / MP3 | ≤ 15,000,000 bytes, 2–30 s | Up 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.
| Code | Cause |
|---|---|
00003 | Missing multipart boundary or file, wrong file field, no filename extension, or multiple files. |
00200 | Unsupported file extension. |
00202 | Invalid file content, image dimensions or media duration. |
00204 | File or complete request exceeds its byte limit. |
Retrieve an Asset
Get a file URL for an asset in the current organization. Requires Bearer authentication.
GET /v1/assets/{id}
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer (int64) | Yes | Asset ID returned by the upload endpoint. |
Example request
Replace 123456789 with the asset ID.
curl https://api.sand.ai/v1/assets/123456789 \
-H "Authorization: Bearer $SAND_API_KEY"
Response
A successful request returns HTTP 200 OK.
{
"id": 123456789,
"url": "https://files.example.com/start-frame.png?signature=example"
}
| Field | Type | Description |
|---|---|---|
id | integer (int64) | Asset ID. |
url | string | File 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.
DELETE /v1/assets/{id}
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | integer (int64) | Yes | ID of the asset to delete. |
No request body is required.
Example request
Replace 123456789 with the asset ID.
curl -X DELETE https://api.sand.ai/v1/assets/123456789 \
-H "Authorization: Bearer $SAND_API_KEY"
Response
A successful deletion returns HTTP 200 OK.
{ "id": 123456789 }
| Field | Type | Description |
|---|---|---|
id | integer (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.