Skip to main content
POST
/
media
/
generate
Generate Media Asset
curl --request POST \
  --url https://{defaultHost}/media/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>",
  "account_id": "<string>",
  "reference_media": [
    "<string>"
  ]
}
'
import requests

url = "https://{defaultHost}/media/generate"

payload = {
"prompt": "<string>",
"account_id": "<string>",
"reference_media": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: '<string>', account_id: '<string>', reference_media: ['<string>']})
};

fetch('https://{defaultHost}/media/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/media/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => '<string>',
'account_id' => '<string>',
'reference_media' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://{defaultHost}/media/generate"

payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"account_id\": \"<string>\",\n \"reference_media\": [\n \"<string>\"\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{defaultHost}/media/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"account_id\": \"<string>\",\n \"reference_media\": [\n \"<string>\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{defaultHost}/media/generate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"<string>\",\n \"account_id\": \"<string>\",\n \"reference_media\": [\n \"<string>\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "media_type": "video",
  "source": "generated",
  "status": "processing",
  "amount_charged": 123,
  "currency": "<string>",
  "error_message": "<string>",
  "created_at": "<string>",
  "completed_at": "<string>",
  "generation": {
    "prompt": "<string>",
    "reference_media": [
      "<string>"
    ],
    "duration_seconds": 123,
    "resolution": "480p"
  },
  "file": {
    "id": "<string>",
    "url": "<string>"
  }
}
{
"error": {
"type": "<string>",
"message": "<string>"
}
}
{
"error": {
"type": "<string>",
"message": "<string>"
}
}
{
"error": {
"type": "payment_required",
"message": "<string>",
"deposit_url": "<string>"
}
}
{
"error": {
"type": "<string>",
"message": "<string>"
}
}

Authorizations

Authorization
string
header
required

An account API key, account scoped JWT, app API key, or user OAuth token.

Body

application/json
type
enum<string>
required

The kind of media to generate.

Available options:
video,
image
prompt
string
required

What to generate. Up to 2,000 characters.

account_id
string

Account ID, prefixed biz_. Defaults to the account the API key belongs to.

reference_media
string[]

Optional reference image file IDs (file_ prefixed), up to 4. For video the first reference seeds the opening frame.

duration_seconds
enum<integer>

Video length in seconds. Video only; defaults to 5.

Available options:
5,
10,
15
resolution
enum<string>

Video resolution. Video only; defaults to 1080p. 1080p is not supported by Seedance 2.0 Fast or Mini; 4k is only supported by Seedance 2.0.

Available options:
480p,
720p,
1080p,
4k

Response

Generation started.

id
string
required

Media asset ID, prefixed media_.

media_type
enum<string>
required

The kind of media this asset holds.

Available options:
video,
image
Example:

"video"

source
enum<string>
required

How the asset was created. Always generated.

Available options:
generated
Example:

"generated"

status
enum<string>
required

Lifecycle state: processing while generation runs, ready when the file is available, failed when generation failed and the charge was refunded.

Available options:
processing,
ready,
failed
Example:

"processing"

amount_charged
number | null
required

USD amount charged to the account's balance for this generation. null if the generation wasn't billed.

currency
string
required

Currency of amount_charged. Always usd.

error_message
string | null
required

Why generation failed. null unless status is failed.

created_at
string
required

ISO 8601 timestamp when the generation was requested.

completed_at
string | null
required

ISO 8601 timestamp when the asset reached a terminal state. null while processing.

generation
object
required

The inputs the asset was generated from.

file
object | null
required

The produced file, usable anywhere attachments are accepted. null until the asset is ready.