> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ishushka.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ishushka.com/_mcp/server.

# Create a video generation

POST https://api.ishushka.com/v1/videos/generate
Content-Type: application/json

Recommended flow: first call POST /v1/videos/prepare to choose and validate the model settings and review the preliminary estimated_price. Then send those same settings plus the final prompt in this request. The prepare endpoint does not accept a prompt or start a generation. This endpoint starts an asynchronous video generation; no defaults are applied to required settings. Validation checks resolution, then aspect_ratio for that resolution, then size for the selected pair; a 400 validation detail includes allowedValues. Use GET /v1/models?type=video to find available models, poll generation_id until completed, then fetch content_url. The MP4 artifact is retained in R2 for 30 days.

Reference: https://docs.ishushka.com/ishushka-api-actual/video/create-video

## Authentication

- `Authorization` header (bearer token, required) — API key passed as Authorization: Bearer token.

## Request

### Headers

- `Idempotency-Key` (string, optional) — Optional key to make retries of the same create request idempotent.

### Body (application/json)

This endpoint expects a VideoGenerationRequest.

- `model` (string, required) — Video model ID. Find supported IDs using GET /v1/models?type=video.
- `prompt` (string, required) — Text prompt describing the video to generate. Maximum length is 10,000 characters.
- `duration` (integer, required) — Duration in seconds. Must be supported by the selected model.
- `resolution` (string, required) — Output resolution supported by the selected model.
- `aspect_ratio` (string, required) — Output aspect ratio supported by the selected resolution.
- `size` (string, required) — Output size supported by the selected model.
- `generate_audio` (boolean, optional) — Whether to generate audio when the selected model supports it.
- `seed` (integer, optional) — Optional deterministic seed when supported by the selected model.
- `references` (list of VideoReference, optional) — Optional image or video inputs. Supply owned file IDs; external URLs are not accepted.

## Response

### 202

Video generation accepted

- `generation_id` (string, required)
- `status` (enum, required)
  - Allowed values: `pending`, `submitted`, `processing`, `completed`, `failed`, `cancelled`, `timed_out`
- `prompt` (string, required)
- `created_at` (datetime, required)
- `model` (string, optional, nullable)
- `completed_at` (datetime, optional, nullable)
- `content_url` (string, optional, nullable) — Available after completion. Fetching this URL redirects to the generated MP4 stored in R2. The artifact is retained for 30 days, then removed by the hourly cleanup job.
- `failure_code` (string, optional, nullable)
- `failure_message` (string, optional, nullable)

## Errors

### 400 Bad Request Error

Invalid request, unsupported model, or unsupported model settings

- `error` (VideoApiErrorError, optional)

### 402 Payment Required Error

Missing or invalid API key, inactive account, or insufficient funds

- `status` (integer, optional) — HTTP-like status code
- `error` (string, optional) — Error message

### 503 Service Unavailable Error

Billing service temporarily unavailable

- `status` (integer, optional) — HTTP-like status code
- `error` (string, optional) — Error message

## Types

### VideoReference

- `type` (enum, required)
  - Allowed values: `image`, `video`
- `file_id` (string, required) — ID of a file owned by the authenticated account.

### VideoApiErrorError

- `message` (string, optional)
- `type` (string, optional)
- `code` (string, optional)
- `details` (list of VideoValidationError, optional, nullable)

### VideoValidationError

- `code` (string, optional)
- `field` (string, optional)
- `message` (string, optional)
- `amount` (double, optional, nullable)
- `allowedValues` (list of string, optional, nullable) — Supported choices for this field, narrowed by preceding valid selections where applicable.

## Examples

**Request**

```json
{
  "model": "alibaba/happyhorse-1.0",
  "prompt": "string",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "size": "1280x720"
}
```

**Response**

```json
{
  "generation_id": "string",
  "status": "pending",
  "prompt": "string",
  "created_at": "2024-01-15T09:30:00Z",
  "model": "string",
  "completed_at": "2024-01-15T09:30:00Z",
  "content_url": "string",
  "failure_code": "string",
  "failure_message": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.ishushka.com/v1/videos/generate"

payload = {
    "model": "alibaba/happyhorse-1.0",
    "prompt": "string",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "size": "1280x720"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.ishushka.com/v1/videos/generate';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"model":"alibaba/happyhorse-1.0","prompt":"string","duration":5,"resolution":"720p","aspect_ratio":"16:9","size":"1280x720"}'
};

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

```go
package main

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

func main() {

	url := "https://api.ishushka.com/v1/videos/generate"

	payload := strings.NewReader("{\n  \"model\": \"alibaba/happyhorse-1.0\",\n  \"prompt\": \"string\",\n  \"duration\": 5,\n  \"resolution\": \"720p\",\n  \"aspect_ratio\": \"16:9\",\n  \"size\": \"1280x720\"\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
require 'uri'
require 'net/http'

url = URI("https://api.ishushka.com/v1/videos/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  \"model\": \"alibaba/happyhorse-1.0\",\n  \"prompt\": \"string\",\n  \"duration\": 5,\n  \"resolution\": \"720p\",\n  \"aspect_ratio\": \"16:9\",\n  \"size\": \"1280x720\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.ishushka.com/v1/videos/generate")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"alibaba/happyhorse-1.0\",\n  \"prompt\": \"string\",\n  \"duration\": 5,\n  \"resolution\": \"720p\",\n  \"aspect_ratio\": \"16:9\",\n  \"size\": \"1280x720\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.ishushka.com/v1/videos/generate', [
  'body' => '{
  "model": "alibaba/happyhorse-1.0",
  "prompt": "string",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "size": "1280x720"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.ishushka.com/v1/videos/generate");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"alibaba/happyhorse-1.0\",\n  \"prompt\": \"string\",\n  \"duration\": 5,\n  \"resolution\": \"720p\",\n  \"aspect_ratio\": \"16:9\",\n  \"size\": \"1280x720\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "alibaba/happyhorse-1.0",
  "prompt": "string",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "size": "1280x720"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ishushka.com/v1/videos/generate")! 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()
```