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

# Veo 视频生成

> 使用 `POST /v1/videos` 调用 Veo 模型提交异步视频任务。

# Veo 视频生成

Veo 系列用于提交异步视频生成任务，适合文生视频和带参考图的视频生成场景。

* 通过 `model` 选择 `veo_3_1` 或 `veo_3_1-fast`
* 请求体使用 JSON。
* 参考图生视频使用 JSON 字段 `input_reference`。
* 异步处理模式，提交成功后返回 `id` / `task_id`
* 任务状态和结果通过 `GET /v1/videos/{task_id}` 查询

## 当前模型

| 模型             | 说明         |
| -------------- | ---------- |
| `veo_3_1`      | 标准质量视频生成模型 |
| `veo_3_1-fast` | 更快的视频生成模型  |

## 方法与路径

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

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://www.geeknow.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo_3_1",
      "prompt": "在广场中央跳舞，镜头缓慢推进，电影感光照",
      "size": "1280x720",
      "duration": 10
    }'
  ```

  ```bash 文生视频 cURL theme={null}
  curl -X POST https://www.geeknow.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo_3_1-fast",
      "prompt": "一辆红色跑车穿过雨夜街道，路面反射霓虹灯光，镜头低角度跟拍",
      "size": "1280x720",
      "duration": 8
    }'
  ```

  ```bash 参考图生视频 cURL theme={null}
  curl -X POST https://www.geeknow.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "veo_3_1",
      "prompt": "让画面中的人物自然转身，背景保持一致",
      "size": "1280x720",
      "duration": 8,
      "input_reference": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
    }'
  ```

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

  resp = requests.post(
      "https://www.geeknow.top/v1/videos",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "model": "veo_3_1",
          "prompt": "在广场中央跳舞，镜头缓慢推进，电影感光照",
          "size": "1280x720",
          "duration": 10,
      },
      timeout=60,
  )

  print(resp.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://www.geeknow.top/v1/videos", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "veo_3_1",
      prompt: "在广场中央跳舞，镜头缓慢推进，电影感光照",
      size: "1280x720",
      duration: 10,
    }),
  });

  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":    "veo_3_1",
  		"prompt":   "在广场中央跳舞，镜头缓慢推进，电影感光照",
  		"size":     "1280x720",
  		"duration": 10,
  	}

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

  	req, err := http.NewRequest("POST", "https://www.geeknow.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": "veo_3_1",
            "prompt": "在广场中央跳舞，镜头缓慢推进，电影感光照",
            "size": "1280x720",
            "duration": 10
          }
          """;

          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create("https://www.geeknow.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://www.geeknow.top/v1/videos');

  $payload = [
      'model' => 'veo_3_1',
      'prompt' => '在广场中央跳舞，镜头缓慢推进，电影感光照',
      'size' => '1280x720',
      'duration' => 10,
  ];

  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://www.geeknow.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: "veo_3_1",
    prompt: "在广场中央跳舞，镜头缓慢推进，电影感光照",
    size: "1280x720",
    duration: 10
  })

  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://www.geeknow.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": "veo_3_1",
      "prompt": "在广场中央跳舞，镜头缓慢推进，电影感光照",
      "size": "1280x720",
      "duration": 10
  ]

  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 = "veo_3_1",
      prompt = "在广场中央跳舞，镜头缓慢推进，电影感光照",
      size = "1280x720",
      duration = 10
  };

  using var request = new HttpRequestMessage(HttpMethod.Post, "https://www.geeknow.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': 'veo_3_1',
      'prompt': '在广场中央跳舞，镜头缓慢推进，电影感光照',
      'size': '1280x720',
      'duration': 10,
    };

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

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

## 响应示例

<ResponseExample>
  ```json 200 - 任务已提交 theme={null}
  {
    "id": "video_abc123",
    "task_id": "video_abc123",
    "object": "video",
    "model": "veo_3_1",
    "status": "queued",
    "progress": 0,
    "created_at": 1735689600
  }
  ```

  ```json 400 - 参数错误 theme={null}
  {
    "code": "invalid_request",
    "message": "prompt is required",
    "data": null
  }
  ```

  ```json 401 - 认证失败 theme={null}
  {
    "code": "unauthorized",
    "message": "无效的令牌",
    "data": null
  }
  ```

  ```json 402 - 额度不足 theme={null}
  {
    "code": "insufficient_quota",
    "message": "用户额度不足",
    "data": null
  }
  ```

  ```json 429 - 请求过多 theme={null}
  {
    "code": "rate_limit_exceeded",
    "message": "当前分组上游负载已饱和，请稍后再试",
    "data": null
  }
  ```

  ```json 500 - 服务端错误 theme={null}
  {
    "code": "do_request_failed",
    "message": "请求处理失败",
    "data": null
  }
  ```
</ResponseExample>

## 认证

使用 Bearer Token 认证：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Body

<ParamField body="model" type="string" required>
  模型名称。可选值：`veo_3_1`、`veo_3_1-fast`。
</ParamField>

<ParamField body="prompt" type="string" required>
  视频提示词。建议描述主体、动作、镜头、场景、光照和风格。
</ParamField>

<ParamField body="size" type="string">
  输出尺寸。常见值：`1280x720`、`720x1280`。横向尺寸通常对应 `16:9`，纵向尺寸通常对应 `9:16`。
</ParamField>

<ParamField body="duration" type="integer">
  目标时长，单位为秒。不同模型可用时长可能不同，建议使用当前模型支持的常见值，例如 `8` 或 `10`。
</ParamField>

<ParamField body="input_reference" type="string | array<string>">
  参考图字段。JSON 中可传图片 URL、base64 或 data URI；如果传入多张，实际效果取决于当前模型支持。
</ParamField>

## Response

<ResponseField name="id" type="string">
  视频任务 ID。查询任务时使用这个值。
</ResponseField>

<ResponseField name="task_id" type="string">
  兼容字段，通常与 `id` 相同。
</ResponseField>

<ResponseField name="object" type="string">
  固定为 `video`。
</ResponseField>

<ResponseField name="model" type="string">
  本次请求使用的模型。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态。常见值包括 `queued`、`in_progress`、`completed`、`failed`。
</ResponseField>

<ResponseField name="progress" type="integer">
  任务进度百分比。
</ResponseField>

<ResponseField name="created_at" type="integer">
  任务创建时间，Unix 秒级时间戳。
</ResponseField>

<ResponseField name="completed_at" type="integer">
  任务完成时间，Unix 秒级时间戳。任务完成后返回。
</ResponseField>

<ResponseField name="video_url" type="string">
  视频结果地址。任务完成后可在查询接口返回。
</ResponseField>

<ResponseField name="error" type="object">
  任务失败时返回的错误信息。
</ResponseField>

## 使用场景

| 场景     | 推荐参数                                                 |
| ------ | ---------------------------------------------------- |
| 文生视频   | `model`、`prompt`、`size`、`duration`                   |
| 参考图生视频 | `model`、`prompt`、`size`、`duration`、`input_reference` |

## 注意事项

* 这是异步接口，提交成功不代表视频已经生成完成。
* 提交后请使用 `GET /v1/videos/{task_id}` 查询任务状态。
* 参考图建议使用清晰主体和明确构图，避免过小或过度压缩的图片。
* 不同模型和账户配置可能影响可用时长、尺寸和预计耗时。

## 相关接口

* [Veo 视频概览](./overview)
* [Veo 任务查询](./query)
