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

# 国产视频模型生成

> 使用 `POST /v1/videos` 提交国产视频模型任务，覆盖文生、图生、参考图、参考视频、首尾帧、动作控制、数字人、对口型和模板特效。

# 国产视频模型生成

国产视频模型统一使用 magic 视频接口提交任务。请求时传入基础模型或组合计费模型，接口会根据模型、分辨率、场景和音频等参数应用对应生成配置与计费规则。

## 方法与路径

```http theme={null}
POST /v1/videos
```

<RequestExample>
  ```bash 标准请求 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "Kling-3.0-Omni",
      "prompt": "死寂系统空间中，角色被蓝色面板照亮",
      "seconds": "15",
      "size": "1280x720"
    }'
  ```

  ```bash 文生视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "Vidu-q2",
      "prompt": "赛博朋克城市夜景，镜头缓慢推进",
      "seconds": "5",
      "size": "1280x720"
    }'
  ```

  ```bash 图生视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "Vidu-q2-pro",
      "prompt": "让人物向前走并微笑",
      "image": "https://example.com/character.png",
      "seconds": "5",
      "size": "720x1280"
    }'
  ```

  ```bash 多图参考 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "Kling-3.0-Omni",
      "prompt": "参考多张图片中的人物和场景风格生成视频",
      "images": [
        "https://example.com/ref-1.png",
        "https://example.com/ref-2.png"
      ],
      "seconds": "6",
      "size": "1280x720"
    }'
  ```

  ```python Python theme={null}
  import requests

  resp = requests.post(
      "https://magic666.top/v1/videos",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "model": "Kling-3.0-Omni",
          "prompt": "死寂系统空间中，角色被蓝色面板照亮",
          "seconds": "15",
          "size": "1280x720",
      },
      timeout=60,
  )
  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://magic666.top/v1/videos", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "Kling-3.0-Omni",
      prompt: "死寂系统空间中，角色被蓝色面板照亮",
      seconds: "15",
      size: "1280x720",
    }),
  });

  console.log(await response.json());
  ```

  ```go Go theme={null}
  package main

  import (
  	"bytes"
  	"encoding/json"
  	"fmt"
  	"io"
  	"net/http"
  )

  func main() {
  	payload := map[string]interface{}{
  		"model":   "Kling-3.0-Omni",
  		"prompt":  "死寂系统空间中，角色被蓝色面板照亮",
  		"seconds": "15",
  		"size":    "1280x720",
  	}

  	body, err := json.Marshal(payload)
  	if err != nil {
  		panic(err)
  	}

  	req, err := http.NewRequest("POST", "https://magic666.top/v1/videos", bytes.NewReader(body))
  	if err != nil {
  		panic(err)
  	}
  	req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
  	req.Header.Set("Content-Type", "application/json")

  	resp, err := http.DefaultClient.Do(req)
  	if err != nil {
  		panic(err)
  	}
  	defer resp.Body.Close()

  	respBody, err := io.ReadAll(resp.Body)
  	if err != nil {
  		panic(err)
  	}
  	fmt.Println(string(respBody))
  }
  ```

  ```java Java theme={null}
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;

  public class Main {
      public static void main(String[] args) throws Exception {
          String json = """
          {
            "model": "Kling-3.0-Omni",
            "prompt": "死寂系统空间中，角色被蓝色面板照亮",
            "seconds": "15",
            "size": "1280x720"
          }
          """;

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://magic666.top/v1/videos"))
              .header("Authorization", "Bearer YOUR_API_KEY")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(json))
              .build();

          HttpResponse<String> response = HttpClient.newHttpClient()
              .send(request, HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://magic666.top/v1/videos');

  $payload = [
      'model' => 'Kling-3.0-Omni',
      'prompt' => '死寂系统空间中，角色被蓝色面板照亮',
      'seconds' => '15',
      'size' => '1280x720',
  ];

  curl_setopt_array($ch, [
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer YOUR_API_KEY',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode($payload),
      CURLOPT_RETURNTRANSFER => true,
  ]);

  $response = curl_exec($ch);
  if ($response === false) {
      throw new RuntimeException(curl_error($ch));
  }

  curl_close($ch);
  echo $response;
  ```

  ```ruby Ruby theme={null}
  require "net/http"
  require "uri"
  require "json"

  uri = URI("https://magic666.top/v1/videos")
  request = Net::HTTP::Post.new(uri)
  request["Authorization"] = "Bearer YOUR_API_KEY"
  request["Content-Type"] = "application/json"

  request.body = JSON.generate({
    model: "Kling-3.0-Omni",
    prompt: "死寂系统空间中，角色被蓝色面板照亮",
    seconds: "15",
    size: "1280x720"
  })

  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end

  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://magic666.top/v1/videos")!
  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")

  let payload: [String: Any] = [
      "model": "Kling-3.0-Omni",
      "prompt": "死寂系统空间中，角色被蓝色面板照亮",
      "seconds": "15",
      "size": "1280x720"
  ]

  request.httpBody = try JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, _, error in
      if let error {
          print(error)
          return
      }
      if let data, let text = String(data: data, encoding: .utf8) {
          print(text)
      }
  }

  task.resume()
  RunLoop.main.run()
  ```

  ```csharp C# theme={null}
  using System.Net.Http.Headers;
  using System.Text;
  using System.Text.Json;

  using var client = new HttpClient();

  var payload = new
  {
      model = "Kling-3.0-Omni",
      prompt = "死寂系统空间中，角色被蓝色面板照亮",
      seconds = "15",
      size = "1280x720"
  };

  using var request = new HttpRequestMessage(HttpMethod.Post, "https://magic666.top/v1/videos");
  request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "YOUR_API_KEY");
  request.Content = new StringContent(
      JsonSerializer.Serialize(payload),
      Encoding.UTF8,
      "application/json"
  );

  using var response = await client.SendAsync(request);
  Console.WriteLine(await response.Content.ReadAsStringAsync());
  ```

  ```dart Dart theme={null}
  import 'dart:convert';
  import 'package:http/http.dart' as http;

  Future<void> main() async {
    final payload = {
      'model': 'Kling-3.0-Omni',
      'prompt': '死寂系统空间中，角色被蓝色面板照亮',
      'seconds': '15',
      'size': '1280x720',
    };

    final response = await http.post(
      Uri.parse('https://magic666.top/v1/videos'),
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: jsonEncode(payload),
    );

    print(response.body);
  }
  ```
</RequestExample>

## 请求字段

<ParamField body="model" type="string" required>
  模型名称。推荐传基础模型，例如 `Kling-2.6`、`Vidu-q2-pro`、`GV-3.1-fast`；也可以直接传组合计费模型，例如 `kling-3.0-omni-1080p-ref-audio`、`vidu-q2-pro-reference-1080p-offpeak`。
</ParamField>

<ParamField body="prompt" type="string" required>
  提示词。文生视频必须传；图生、参考图、动作控制等场景也建议传清楚运动、镜头、主体和风格。
</ParamField>

<ParamField body="seconds" type="string | integer">
  生成时长。顶层 `seconds` 优先级最高，例如 `"seconds": "5"`。
</ParamField>

<ParamField body="duration" type="integer">
  时长兼容字段。优先级低于顶层 `seconds`。
</ParamField>

<ParamField body="size" type="string">
  快速尺寸字段，支持 `720P` / `1080P`，也支持 `WxH`，例如 `720x1280`。
</ParamField>

<ParamField body="image" type="string">
  单张参考图或首帧图。当前支持可访问的 `http(s)` 图片 URL 或文件 ID；不支持 `data:image/...;base64,...` 这类 base64 data URI。
</ParamField>

<ParamField body="images" type="array<string>">
  多张参考图。每张图会作为图片素材处理；最多 3 张。
</ParamField>

<ParamField body="input_reference" type="string | array<string>">
  参考图兼容字段。国产模型侧建议优先使用 `image` / `images`。
</ParamField>

## 参数优先级

时长优先级：

1. 顶层 `seconds`
2. 顶层 `duration`
3. 默认 `5`

分辨率优先级：

1. 顶层 `size`
2. 模型默认值

文生 / 图生判定：

* 有 `image`、`images` 或 `input_reference` 这类参考输入时，按图生或参考输入场景处理。
* 没有参考输入时，按文生视频处理。

## 场景字段

| 场景   | 关键字段                                    |
| ---- | --------------------------------------- |
| 文生视频 | `model` + `prompt` + `seconds` + `size` |
| 图生视频 | `image` / `images` / `input_reference`  |
| 多图参考 | `images`                                |
| 首尾帧  | 支持的模型可按顺序传入 `images`                    |

## `size` 规则

* 顶层 `size` 支持 `720P` / `1080P`，也支持 `WxH`。
* 当只传 `size=WxH` 时，接口会推导分辨率和宽高比。

示例：

* `size=720x1280` + `model=Kling-3.0-Omni` 会推导为竖屏视频。
* `size=1280x720` + `model=Kling-3.0-Omni` 会推导为横屏视频。

## 相关页面

* [国产视频模型概览](./overview)
* [国产视频模型查询](./query)
