> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.joytokens.ai/llms.txt.

# Video Generation

POST https://api.joytokens.ai/openai/v1/videos
Content-Type: application/json

Creates an asynchronous video generation task using an OpenAI-compatible request. Applicable model is `Doubao-Seedance-2.5`; omit `model` to use `auto` and let the gateway route within the video generation model pool. Supported modes: text-to-video (prompt required), image-to-video (input\_reference as a single image or array, prompt optional), and first-and-last-frame (first\_frame / last\_frame, prompt optional).

The generation endpoint does not accept `input_video`; send it here to receive 400 and use POST /openai/v1/videos/edits for multi-video stitching. Up to 30 images (input\_reference + first\_frame + last\_frame combined) may be sent per request.

Returns 202 with a task\_id. Fees are pre-deducted at creation and settled on completion based on the upstream output\_tokens (overpayment refunded, failure automatically refunded). Poll GET /openai/v1/videos/\{task\_id} every 3\~10 seconds until the task reaches a terminal state (completed / failed). Task records are kept for 24 hours.

Reference: https://docs.joytokens.ai/open-api/api-reference/compatible-model-ap-is/videos/create-video-generation

## Authentication

- `Authorization` header (bearer token, required) — Use `Authorization: Bearer $JOY_TOKEN_API_KEY`.

## Request

### Body (application/json)

This endpoint expects a VideoGenerationRequest.

- `model` (string, optional) — Model name, e.g. `Doubao-Seedance-2.5`. Omit to use `auto` and let the gateway route within the video generation model pool.
- `prompt` (string, optional) — Text description. Required for text-to-video; may be omitted when any image input (input_reference / first_frame / last_frame) is present.
- `size` (string, optional) — Resolution/aspect. Accepts `480p` / `720p` / `1080p` or `WIDTHxHEIGHT` (e.g. `1280x720`, converted to the aspect ratio and resolution). Aspect ratios support 16:9 and 9:16; use parameters.aspect_ratio for other ratios.
- `duration` (integer, optional) — Video length in seconds. Continuous 2\~30 range (Seedance 2.5), default 8. Out-of-range values are clamped (\<2 becomes 2, >30 becomes 30). Stitch longer videos through POST /openai/v1/videos/edits.
- `input_reference` (VideoGenerationRequestInputReference, optional) — Reference image URL(s). A single string is one image; an array is multiple images for multi-subject reference (each sent with the reference_image role). Up to 30 images per request (input_reference + first_frame + last_frame combined), otherwise 400.
- `first_frame` (string, optional) — First-frame image URL (first_frame role).
- `last_frame` (string, optional) — Last-frame image URL (last_frame role).
- `user` (string, optional) — Optional end-user identifier for abuse tracking.
- `parameters` (VideoGenerationRequestParameters, optional) — Native upstream parameter passthrough; snake_case field names are preferred (camelCase accepted). Supports aspect_ratio, resolution, duration_seconds, generate_audio, seed, negative_prompt, compression_quality, and person_generation. `fps`, `sample_count`, and 4K resolutions are not supported (rejected or ignored). Top-level duration / size explicitly provided take precedence.

## Response

### 202

Task accepted. Fees are settled on task completion based on actual usage.

- `task_id` (string, required) — Task id used for polling and download.
- `status` (enum, required) — Always processing on creation.
  - Allowed values: `processing`
- `progress` (integer, required) — Progress percentage, always 0 on creation.
- `model` (string, required) — The actually selected model name (the real model after auto routing).
- `created` (long, required) — Unix timestamp (seconds) of task creation.

## Errors

### 400 Bad Request Error

Missing prompt and media input, input_video sent to the generation endpoint, more than 30 images, or invalid request parameters.

- `error` (ErrorResponseError, required)

### 401 Unauthorized Error

Missing Authorization header.

- `error` (ErrorResponseError, required)

### 403 Forbidden Error

API key invalid or not ACTIVE.

- `error` (ErrorResponseError, required)

### 502 Bad Gateway Error

Upstream did not return a task id; fees are automatically refunded.

- `error` (ErrorResponseError, required)

### 503 Service Unavailable Error

API key validation service or task store temporarily unavailable.

- `error` (ErrorResponseError, required)

## Types

### VideoGenerationRequestInputReference

Reference image URL(s). A single string is one image; an array is multiple images for multi-subject reference (each sent with the reference_image role). Up to 30 images per request (input_reference + first_frame + last_frame combined), otherwise 400.

- string
- list of string

### VideoGenerationRequestParameters

Native upstream parameter passthrough; snake_case field names are preferred (camelCase accepted). Supports aspect_ratio, resolution, duration_seconds, generate_audio, seed, negative_prompt, compression_quality, and person_generation. `fps`, `sample_count`, and 4K resolutions are not supported (rejected or ignored). Top-level duration / size explicitly provided take precedence.

### ErrorResponseError

- `message` (string, required)
- `type` (string, optional)
- `code` (ErrorResponseErrorCode, optional, nullable)

### ErrorResponseErrorCode

- string
- integer

## Examples

### Videos_createVideoGeneration_example

**Response**

```json
{
  "task_id": "vtask-8f3a1c2d9e4b5f6a",
  "status": "processing",
  "progress": 0,
  "model": "Doubao-Seedance-2.5",
  "created": 1760000000
}
```

**SDK Code**

```python Videos_createVideoGeneration_example
import requests

url = "https://api.joytokens.ai/openai/v1/videos"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Videos_createVideoGeneration_example
const url = 'https://api.joytokens.ai/openai/v1/videos';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Videos_createVideoGeneration_example
package main

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

func main() {

	url := "https://api.joytokens.ai/openai/v1/videos"

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Videos_createVideoGeneration_example
require 'uri'
require 'net/http'

url = URI("https://api.joytokens.ai/openai/v1/videos")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Videos_createVideoGeneration_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joytokens.ai/openai/v1/videos")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Videos_createVideoGeneration_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joytokens.ai/openai/v1/videos', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Videos_createVideoGeneration_example
using RestSharp;

var client = new RestClient("https://api.joytokens.ai/openai/v1/videos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Videos_createVideoGeneration_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joytokens.ai/openai/v1/videos")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Text-to-video

**Request**

```json
{
  "model": "auto",
  "prompt": "A movie-style shot of an orange cat running through rainy Tokyo streets",
  "size": "1280x720",
  "duration": 8
}
```

**Response**

```json
{
  "task_id": "vtask-8f3a1c2d9e4b5f6a",
  "status": "processing",
  "progress": 0,
  "model": "Doubao-Seedance-2.5",
  "created": 1760000000
}
```

**SDK Code**

```python Text-to-video
import requests

url = "https://api.joytokens.ai/openai/v1/videos"

payload = {
    "model": "auto",
    "prompt": "A movie-style shot of an orange cat running through rainy Tokyo streets",
    "size": "1280x720",
    "duration": 8
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Text-to-video
const url = 'https://api.joytokens.ai/openai/v1/videos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"auto","prompt":"A movie-style shot of an orange cat running through rainy Tokyo streets","size":"1280x720","duration":8}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Text-to-video
package main

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

func main() {

	url := "https://api.joytokens.ai/openai/v1/videos"

	payload := strings.NewReader("{\n  \"model\": \"auto\",\n  \"prompt\": \"A movie-style shot of an orange cat running through rainy Tokyo streets\",\n  \"size\": \"1280x720\",\n  \"duration\": 8\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(res)
	fmt.Println(string(body))

}
```

```ruby Text-to-video
require 'uri'
require 'net/http'

url = URI("https://api.joytokens.ai/openai/v1/videos")

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  \"model\": \"auto\",\n  \"prompt\": \"A movie-style shot of an orange cat running through rainy Tokyo streets\",\n  \"size\": \"1280x720\",\n  \"duration\": 8\n}"

response = http.request(request)
puts response.read_body
```

```java Text-to-video
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joytokens.ai/openai/v1/videos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"auto\",\n  \"prompt\": \"A movie-style shot of an orange cat running through rainy Tokyo streets\",\n  \"size\": \"1280x720\",\n  \"duration\": 8\n}")
  .asString();
```

```php Text-to-video
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joytokens.ai/openai/v1/videos', [
  'body' => '{
  "model": "auto",
  "prompt": "A movie-style shot of an orange cat running through rainy Tokyo streets",
  "size": "1280x720",
  "duration": 8
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Text-to-video
using RestSharp;

var client = new RestClient("https://api.joytokens.ai/openai/v1/videos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"auto\",\n  \"prompt\": \"A movie-style shot of an orange cat running through rainy Tokyo streets\",\n  \"size\": \"1280x720\",\n  \"duration\": 8\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Text-to-video
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "auto",
  "prompt": "A movie-style shot of an orange cat running through rainy Tokyo streets",
  "size": "1280x720",
  "duration": 8
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joytokens.ai/openai/v1/videos")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Image-to-video with multiple reference images

**Request**

```json
{
  "model": "auto",
  "prompt": "Make the girl in the frame turn her head and smile",
  "input_reference": [
    "https://example.com/girl-face.png",
    "https://example.com/city-background.png"
  ]
}
```

**Response**

```json
{
  "task_id": "vtask-8f3a1c2d9e4b5f6a",
  "status": "processing",
  "progress": 0,
  "model": "Doubao-Seedance-2.5",
  "created": 1760000000
}
```

**SDK Code**

```python Image-to-video with multiple reference images
import requests

url = "https://api.joytokens.ai/openai/v1/videos"

payload = {
    "model": "auto",
    "prompt": "Make the girl in the frame turn her head and smile",
    "input_reference": ["https://example.com/girl-face.png", "https://example.com/city-background.png"]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Image-to-video with multiple reference images
const url = 'https://api.joytokens.ai/openai/v1/videos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"auto","prompt":"Make the girl in the frame turn her head and smile","input_reference":["https://example.com/girl-face.png","https://example.com/city-background.png"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Image-to-video with multiple reference images
package main

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

func main() {

	url := "https://api.joytokens.ai/openai/v1/videos"

	payload := strings.NewReader("{\n  \"model\": \"auto\",\n  \"prompt\": \"Make the girl in the frame turn her head and smile\",\n  \"input_reference\": [\n    \"https://example.com/girl-face.png\",\n    \"https://example.com/city-background.png\"\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(res)
	fmt.Println(string(body))

}
```

```ruby Image-to-video with multiple reference images
require 'uri'
require 'net/http'

url = URI("https://api.joytokens.ai/openai/v1/videos")

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  \"model\": \"auto\",\n  \"prompt\": \"Make the girl in the frame turn her head and smile\",\n  \"input_reference\": [\n    \"https://example.com/girl-face.png\",\n    \"https://example.com/city-background.png\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Image-to-video with multiple reference images
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joytokens.ai/openai/v1/videos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"auto\",\n  \"prompt\": \"Make the girl in the frame turn her head and smile\",\n  \"input_reference\": [\n    \"https://example.com/girl-face.png\",\n    \"https://example.com/city-background.png\"\n  ]\n}")
  .asString();
```

```php Image-to-video with multiple reference images
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joytokens.ai/openai/v1/videos', [
  'body' => '{
  "model": "auto",
  "prompt": "Make the girl in the frame turn her head and smile",
  "input_reference": [
    "https://example.com/girl-face.png",
    "https://example.com/city-background.png"
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Image-to-video with multiple reference images
using RestSharp;

var client = new RestClient("https://api.joytokens.ai/openai/v1/videos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"auto\",\n  \"prompt\": \"Make the girl in the frame turn her head and smile\",\n  \"input_reference\": [\n    \"https://example.com/girl-face.png\",\n    \"https://example.com/city-background.png\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Image-to-video with multiple reference images
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "auto",
  "prompt": "Make the girl in the frame turn her head and smile",
  "input_reference": ["https://example.com/girl-face.png", "https://example.com/city-background.png"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joytokens.ai/openai/v1/videos")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### First-and-last-frame

**Request**

```json
{
  "model": "auto",
  "prompt": "Day-to-night city timelapse",
  "duration": 10,
  "first_frame": "https://example.com/day.png",
  "last_frame": "https://example.com/night.png"
}
```

**Response**

```json
{
  "task_id": "vtask-8f3a1c2d9e4b5f6a",
  "status": "processing",
  "progress": 0,
  "model": "Doubao-Seedance-2.5",
  "created": 1760000000
}
```

**SDK Code**

```python First-and-last-frame
import requests

url = "https://api.joytokens.ai/openai/v1/videos"

payload = {
    "model": "auto",
    "prompt": "Day-to-night city timelapse",
    "duration": 10,
    "first_frame": "https://example.com/day.png",
    "last_frame": "https://example.com/night.png"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript First-and-last-frame
const url = 'https://api.joytokens.ai/openai/v1/videos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"auto","prompt":"Day-to-night city timelapse","duration":10,"first_frame":"https://example.com/day.png","last_frame":"https://example.com/night.png"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go First-and-last-frame
package main

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

func main() {

	url := "https://api.joytokens.ai/openai/v1/videos"

	payload := strings.NewReader("{\n  \"model\": \"auto\",\n  \"prompt\": \"Day-to-night city timelapse\",\n  \"duration\": 10,\n  \"first_frame\": \"https://example.com/day.png\",\n  \"last_frame\": \"https://example.com/night.png\"\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(res)
	fmt.Println(string(body))

}
```

```ruby First-and-last-frame
require 'uri'
require 'net/http'

url = URI("https://api.joytokens.ai/openai/v1/videos")

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  \"model\": \"auto\",\n  \"prompt\": \"Day-to-night city timelapse\",\n  \"duration\": 10,\n  \"first_frame\": \"https://example.com/day.png\",\n  \"last_frame\": \"https://example.com/night.png\"\n}"

response = http.request(request)
puts response.read_body
```

```java First-and-last-frame
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joytokens.ai/openai/v1/videos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"auto\",\n  \"prompt\": \"Day-to-night city timelapse\",\n  \"duration\": 10,\n  \"first_frame\": \"https://example.com/day.png\",\n  \"last_frame\": \"https://example.com/night.png\"\n}")
  .asString();
```

```php First-and-last-frame
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joytokens.ai/openai/v1/videos', [
  'body' => '{
  "model": "auto",
  "prompt": "Day-to-night city timelapse",
  "duration": 10,
  "first_frame": "https://example.com/day.png",
  "last_frame": "https://example.com/night.png"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp First-and-last-frame
using RestSharp;

var client = new RestClient("https://api.joytokens.ai/openai/v1/videos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"auto\",\n  \"prompt\": \"Day-to-night city timelapse\",\n  \"duration\": 10,\n  \"first_frame\": \"https://example.com/day.png\",\n  \"last_frame\": \"https://example.com/night.png\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift First-and-last-frame
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "auto",
  "prompt": "Day-to-night city timelapse",
  "duration": 10,
  "first_frame": "https://example.com/day.png",
  "last_frame": "https://example.com/night.png"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joytokens.ai/openai/v1/videos")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Native upstream parameters

**Request**

```json
{
  "model": "auto",
  "prompt": "Waves crashing on a beach",
  "parameters": {
    "aspect_ratio": "9:16",
    "duration_seconds": 12,
    "generate_audio": true,
    "resolution": "1080p",
    "seed": 42
  }
}
```

**Response**

```json
{
  "task_id": "vtask-8f3a1c2d9e4b5f6a",
  "status": "processing",
  "progress": 0,
  "model": "Doubao-Seedance-2.5",
  "created": 1760000000
}
```

**SDK Code**

```python Native upstream parameters
import requests

url = "https://api.joytokens.ai/openai/v1/videos"

payload = {
    "model": "auto",
    "prompt": "Waves crashing on a beach",
    "parameters": {
        "aspect_ratio": "9:16",
        "duration_seconds": 12,
        "generate_audio": True,
        "resolution": "1080p",
        "seed": 42
    }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Native upstream parameters
const url = 'https://api.joytokens.ai/openai/v1/videos';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"auto","prompt":"Waves crashing on a beach","parameters":{"aspect_ratio":"9:16","duration_seconds":12,"generate_audio":true,"resolution":"1080p","seed":42}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Native upstream parameters
package main

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

func main() {

	url := "https://api.joytokens.ai/openai/v1/videos"

	payload := strings.NewReader("{\n  \"model\": \"auto\",\n  \"prompt\": \"Waves crashing on a beach\",\n  \"parameters\": {\n    \"aspect_ratio\": \"9:16\",\n    \"duration_seconds\": 12,\n    \"generate_audio\": true,\n    \"resolution\": \"1080p\",\n    \"seed\": 42\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(res)
	fmt.Println(string(body))

}
```

```ruby Native upstream parameters
require 'uri'
require 'net/http'

url = URI("https://api.joytokens.ai/openai/v1/videos")

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  \"model\": \"auto\",\n  \"prompt\": \"Waves crashing on a beach\",\n  \"parameters\": {\n    \"aspect_ratio\": \"9:16\",\n    \"duration_seconds\": 12,\n    \"generate_audio\": true,\n    \"resolution\": \"1080p\",\n    \"seed\": 42\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Native upstream parameters
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.joytokens.ai/openai/v1/videos")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"auto\",\n  \"prompt\": \"Waves crashing on a beach\",\n  \"parameters\": {\n    \"aspect_ratio\": \"9:16\",\n    \"duration_seconds\": 12,\n    \"generate_audio\": true,\n    \"resolution\": \"1080p\",\n    \"seed\": 42\n  }\n}")
  .asString();
```

```php Native upstream parameters
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.joytokens.ai/openai/v1/videos', [
  'body' => '{
  "model": "auto",
  "prompt": "Waves crashing on a beach",
  "parameters": {
    "aspect_ratio": "9:16",
    "duration_seconds": 12,
    "generate_audio": true,
    "resolution": "1080p",
    "seed": 42
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Native upstream parameters
using RestSharp;

var client = new RestClient("https://api.joytokens.ai/openai/v1/videos");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"auto\",\n  \"prompt\": \"Waves crashing on a beach\",\n  \"parameters\": {\n    \"aspect_ratio\": \"9:16\",\n    \"duration_seconds\": 12,\n    \"generate_audio\": true,\n    \"resolution\": \"1080p\",\n    \"seed\": 42\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Native upstream parameters
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "auto",
  "prompt": "Waves crashing on a beach",
  "parameters": [
    "aspect_ratio": "9:16",
    "duration_seconds": 12,
    "generate_audio": true,
    "resolution": "1080p",
    "seed": 42
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.joytokens.ai/openai/v1/videos")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```