> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiandgpu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Video

export const TextToVideoParams = ({model}) => {
  const multimodalExample = `{
    "model": "${model}",
    "content": [
         {
            "type": "text",
            "text": "生成视频描述，越详细生成效果越好..."
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "<path-to-your-image-url>"
            },
            "role": "reference_image"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "<path-to-your-image-url>"
            },
            "role": "reference_image"
        },
        {
          "type": "video_url",
          "video_url": {
              "url": "<path-to-your-image-url>"
          },
          "role": "reference_video"
        },
        {
          "type": "audio_url",
          "audio_url": {
              "url": "<path-to-your-image-url>"
          },
          "role": "reference_audio"
        }
    ],
    "generate_audio":true,
    "ratio": "16:9",
    "duration": 11,
    "watermark": false
}`;
  return <>
      <h2>Parameters</h2>
      <h3>Core Parameters</h3>
      <table>
        <thead>
          <tr>
            <th style={{
    textAlign: 'left'
  }}>Field</th>
            <th style={{
    textAlign: 'left'
  }}>Type</th>
            <th style={{
    textAlign: 'left'
  }}>Required</th>
            <th style={{
    textAlign: 'left'
  }}>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><code>model</code></td>
            <td><code>string</code></td>
            <td>✅</td>
            <td>The model ID to use for the request. Value: <code>{model}</code>.</td>
          </tr>
          <tr>
            <td><code>content</code></td>
            <td><code>array</code></td>
            <td>✅</td>
            <td>Content of the current conversation with the model. For single-turn queries, this contains one instance. For multi-turn queries (e.g., chat), this contains the conversation history and the latest request.</td>
          </tr>
        </tbody>
      </table>

      <h3>Content Structure</h3>
      <table>
        <thead>
          <tr>
            <th style={{
    textAlign: 'left'
  }}>Field</th>
            <th style={{
    textAlign: 'left'
  }}>Type</th>
            <th style={{
    textAlign: 'left'
  }}>Required</th>
            <th style={{
    textAlign: 'left'
  }}>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><code>&gt;content.type</code></td>
            <td><code>enum</code></td>
            <td>✅</td>
            <td>The type of the content part. Possible values: <code>text</code>, <code>image_url</code>, <code>video_url</code>, <code>audio_url</code>.</td>
          </tr>
          <tr>
            <td><code>&gt;content.text</code></td>
            <td><code>string</code></td>
            <td>-</td>
            <td>The text content of the part. Required when <code>type</code> is <code>text</code>.</td>
          </tr>
          <tr>
            <td><code>&gt;content.role</code></td>
            <td><code>enum</code></td>
            <td>-</td>
            <td>Required when type is not <code>text</code>. Position or intent of an image, video, or audio part. Allowed values: <code>first_frame</code>, <code>last_frame</code>, <code>reference_image</code>, <code>reference_video</code>, <code>reference_audio</code>.</td>
          </tr>
          <tr>
            <td><code>&gt;content.image_url</code></td>
            <td><code>object</code></td>
            <td>-</td>
            <td>The image content of the part. Required when <code>type</code> is <code>image_url</code>.</td>
          </tr>
          <tr>
            <td><code>&gt;&gt;content.image_url.url</code></td>
            <td><code>string</code></td>
            <td>-</td>
            <td>The URL of the image. Supports HTTP/HTTPS URLs or base64-encoded data URIs (e.g., <code>data:image/jpeg;base64,...</code>).</td>
          </tr>
          <tr>
            <td><code>&gt;content.video_url</code></td>
            <td><code>object</code></td>
            <td>-</td>
            <td>The video payload for the part. Required when <code>type</code> is <code>video_url</code>.</td>
          </tr>
          <tr>
            <td><code>&gt;&gt;content.video_url.url</code></td>
            <td><code>string</code></td>
            <td>-</td>
            <td>The URL of the video. Supports HTTP/HTTPS URLs.</td>
          </tr>
        </tbody>
      </table>

      <h3>Multimodal Input</h3>
      <CodeBlock language="json">
        {multimodalExample}
      </CodeBlock>

      <h3>Advanced Parameters</h3>
      <table>
        <thead>
          <tr>
            <th style={{
    textAlign: 'left'
  }}>Field</th>
            <th style={{
    textAlign: 'left'
  }}>Type</th>
            <th style={{
    textAlign: 'left'
  }}>Required</th>
            <th style={{
    textAlign: 'left'
  }}>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td><code>callback_url</code></td>
            <td><code>string</code></td>
            <td>-</td>
            <td>Callback URL for generation task notifications. When the video task status changes, the API sends a <code>POST</code> request to this endpoint.</td>
          </tr>
          <tr>
            <td><code>return_last_frame</code></td>
            <td><code>boolean</code></td>
            <td>-</td>
            <td>Whether to return the last frame of the generated video as an image. Default: <code>false</code>.</td>
          </tr>
          <tr>
            <td><code>execution_expires_after</code></td>
            <td><code>integer</code></td>
            <td>-</td>
            <td>Task timeout in seconds after submission, counted from the task <strong>created at</strong> timestamp. Default: <code>172800</code> (48 hours). Allowed range: <code>[3600, 259200]</code>.</td>
          </tr>
          <tr>
            <td><code>generate_audio</code></td>
            <td><code>boolean</code></td>
            <td>-</td>
            <td>Whether the generated video includes audio synchronized with the visuals. Default: <code>true</code>.</td>
          </tr>
          <tr>
            <td><code>ratio</code></td>
            <td><code>enum</code></td>
            <td>-</td>
            <td>Output aspect ratio. Default: <code>adaptive</code>. Allowed values: <code>adaptive</code>, <code>16:9</code>, <code>4:3</code>, <code>1:1</code>, <code>3:3</code>, <code>9:16</code>, <code>21:9</code>.</td>
          </tr>
          <tr>
            <td><code>resolution</code></td>
            <td><code>enum</code></td>
            <td>-</td>
            <td>Video resolution. Default: <code>720p</code>. Allowed values: <code>480p</code>, <code>720p</code>, <code>1080p</code>.</td>
          </tr>
          <tr>
            <td><code>duration</code></td>
            <td><code>integer</code></td>
            <td>-</td>
            <td>Video length in whole seconds: allowed range <code>[4, 15]</code>, or <code>-1</code> to let the model pick a suitable integer duration within valid bounds.</td>
          </tr>
          <tr>
            <td><code>frames</code></td>
            <td><code>integer</code></td>
            <td>-</td>
            <td>Use either <code>duration</code> or <code>frames</code>; if both are set, <code>frames</code> takes precedence. Prefer <code>frames</code> when you need sub‑second clip length control.</td>
          </tr>
          <tr>
            <td><code>seed</code></td>
            <td><code>integer</code></td>
            <td>-</td>
            <td>Random seed for reproducibility. Allowed range: <code>[-1, 2^32 - 1]</code>.</td>
          </tr>
          <tr>
            <td><code>watermark</code></td>
            <td><code>boolean</code></td>
            <td>-</td>
            <td>Whether the output video includes a watermark. Default: <code>false</code>.</td>
          </tr>
          <tr>
            <td><code>tools</code></td>
            <td><code>array</code></td>
            <td>-</td>
            <td>Tools the model may invoke for this request.</td>
          </tr>
          <tr>
            <td><code>safety_identifier</code></td>
            <td><code>string</code></td>
            <td>-</td>
            <td>Unique identifier for the end user (for safety and policy enforcement).</td>
          </tr>
        </tbody>
      </table>
    </>;
};

export const ByteDanceChatResponse = ({successJson, successTitle = "200 - Success"}) => {
  const error400 = `{
    "error": {
        "code": "invalid_params",
        "message": "parameter 'messages' is required",
        "param": null,
        "type": "invalid_request_error"
    }
}`;
  const error401 = `{
    "error": {
        "code": "auth_missing",
        "message": "Missing Authorization Header",
        "param": null,
        "type": "authentication_error"
    }
}`;
  const error402 = `{
   "error": {
        "code": "insufficient_balance",
        "message": "Insufficient balance",
        "param": null,
        "type": "authentication_error"
   }
}`;
  const error403 = `{
   "error": {
        "code": "permission_denied",
        "message": "Permission denied on this model",
        "param": null,
        "type": "authentication_error"
   }
}`;
  const error404 = `{
   "error": {
        "code": "invalid_url",
        "message": "Invalid URL",
        "param": null,
        "type": "invalid_request_error"
   }
}`;
  const error429 = `{
   "error": {
        "code": "rate_limit_exceeded",
        "message": "Too many requests",
        "param": null,
        "type": "rate_limit_error"
   }
}`;
  const error500 = `{
    "error": {
        "code": "internal_server_error",
        "message": "Internal server error",
        "param": null,
        "type": "server_error"
   }
}`;
  return <>
      <h2>Response Examples</h2>

      <CodeGroup>
        <CodeBlock language={"json"} filename={successTitle}>
          {successJson}
        </CodeBlock>
        <CodeBlock language="json" filename="400 - Bad Request">
          {error400}
        </CodeBlock>
        <CodeBlock language="json" filename="401 - Unauthorized">
          {error401}
        </CodeBlock>
        <CodeBlock language="json" filename="402 - Insufficient Balance">
          {error402}
        </CodeBlock>
        <CodeBlock language="json" filename="403 - Permission Denied">
          {error403}
        </CodeBlock>
        <CodeBlock language="json" filename="404 - Invalid URL">
          {error404}
        </CodeBlock>
        <CodeBlock language="json" filename="429 - Too Many Requests">
          {error429}
        </CodeBlock>
        <CodeBlock language="json" filename="500 - Internal Server Error">
          {error500}
        </CodeBlock>
      </CodeGroup>
    </>;
};

export const TextToVideoOfficialRequest = ({model}) => {
  const url = "https://aiandgpu.com/api/v3/contents/generations/tasks";
  const curlExample = `curl -X POST '${url}' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer <YOUR_API_KEY>' \\
-d '{
  "model": "${model}",
  "content": [
    {
      "type": "text",
      "text": "写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠"
    }
  ],
  "generate_audio": true,
  "ratio": "16:9",
  "duration": 5,
  "watermark": false
}'`;
  const pythonExample = `import requests

url = "${url}"

payload = {
    "model": "${model}",
    "content": [
        {
            "type": "text",
            "text": "写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠"
        }
    ],
    "generate_audio": True,
    "ratio": "16:9",
    "duration": 5,
    "watermark": False
}

headers = {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json",
}

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

print(response.json())`;
  const jsExample = `const response = await fetch('${url}', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <YOUR_API_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: '${model}',
    content: [
      {
        type: 'text',
        text: '写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠'
      }
    ],
    generate_audio: true,
    ratio: '16:9',
    duration: 5,
    watermark: false
  })
});

const data = await response.json();
console.log(data);`;
  const goExample = `package main

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

func main() {
\turl := "${url}"

\tpayload := strings.NewReader(\`{
  "model": "${model}",
  "content": [
    {
      "type": "text",
      "text": "写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠"
    }
  ],
  "generate_audio": true,
  "ratio": "16:9",
  "duration": 5,
  "watermark": false
}\`)

\treq, _ := http.NewRequest("POST", url, payload)
\treq.Header.Add("Authorization", "Bearer <YOUR_API_KEY>")
\treq.Header.Add("Content-Type", "application/json")

\tres, _ := http.DefaultClient.Do(req)
\tdefer res.Body.Close()

\tbody, _ := io.ReadAll(res.Body)
\tfmt.Println(string(body))
}`;
  const javaExample = `import java.net.http.*;
import java.net.URI;

HttpClient client = HttpClient.newHttpClient();

String body = """
{
  "model": "${model}",
  "content": [
    {
      "type": "text",
      "text": "写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠"
    }
  ],
  "generate_audio": true,
  "ratio": "16:9",
  "duration": 5,
  "watermark": false
}
""";

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("${url}"))
    .header("Authorization", "Bearer <YOUR_API_KEY>")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());`;
  const phpExample = `<?php

$curl = curl_init();

$payload = json_encode([
    'model' => '${model}',
    'content' => [
        [
            'type' => 'text',
            'text' => '写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠',
        ],
    ],
    'generate_audio' => true,
    'ratio' => '16:9',
    'duration' => 5,
    'watermark' => false,
]);

curl_setopt_array($curl, [
    CURLOPT_URL => "${url}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer <YOUR_API_KEY>",
        "Content-Type: application/json",
    ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;`;
  const csharpExample = `using System.Net.Http;
using System.Text;

var client = new HttpClient();

var payload = @"{
    ""model"": ""${model}"",
    ""content"": [
        {
            ""type"": ""text"",
            ""text"": ""写实风格，晴朗的蓝天之下，一大片白色的雏菊花田，镜头逐渐拉近，最终定格在一朵雏菊花的特写上，花瓣上有几颗晶莹的露珠""
        }
    ],
    ""generate_audio"": true,
    ""ratio"": ""16:9"",
    ""duration"": 5,
    ""watermark"": false
}";

var request = new HttpRequestMessage(HttpMethod.Post, "${url}");
request.Headers.Add("Authorization", "Bearer <YOUR_API_KEY>");
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");

var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);`;
  return <>
      <h2>Request Examples</h2>

      <CodeGroup>
        <CodeBlock language="shellscript" filename="cURL">
          {curlExample}
        </CodeBlock>
        <CodeBlock language="python" filename="Python">
          {pythonExample}
        </CodeBlock>
        <CodeBlock language="javascript" filename="JavaScript">
          {jsExample}
        </CodeBlock>
        <CodeBlock language="go" filename="Go">
          {goExample}
        </CodeBlock>
        <CodeBlock language="java" filename="Java">
          {javaExample}
        </CodeBlock>
        <CodeBlock language="php" filename="PHP">
          {phpExample}
        </CodeBlock>
        <CodeBlock language="csharp" filename="C#">
          {csharpExample}
        </CodeBlock>
      </CodeGroup>
    </>;
};

## Authorization

* **Auth Type**: `Bearer Auth` (In: `header`)
* **Format**: `Authorization: Bearer <YOUR_API_KEY>`
* **Description**: Use `Bearer <YOUR_API_KEY>`. Format: `Authorization: Bearer sk-xxxxxx.`
* **API Key**: where <strong>API Key</strong> is your <a href="https://developer.aiandgpu.com" target="_blank" rel="noopener noreferrer">AGCloud API KEY</a>

<TextToVideoOfficialRequest model="doubao-seedance-2-0" />

<ByteDanceChatResponse
  successJson={`{
    "id": "xxxxx"
}`}
/>

<Note>
  Task status will be: `queued`, `pending`(`running`), `success`(`succeeded`), `failed`, `expired`, `cancelled`
</Note>

<TextToVideoParams model="doubao-seedance-2-0" />
