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

# 生成视频

> 使用大语言模型进行对话交互

> 使用 Sora 模型根据文本或对话生成视频

## 功能说明

使用 OpenAI 旗舰级视频生成模型 Sora 2 生成高保真、长达一分钟的视频。

<Note>
  视频生成通常需要较长时间（120秒以上），请使用流式请求以获取生成进度。
</Note>

## 请求参数

| 名称         | 类型        | 必选 | 说明                            |
| :--------- | :-------- | :- | :---------------------------- |
| `model`    | `string`  | 是  | 模型名称，如 `sora-2` 或 `sora-2-hd` |
| `messages` | `array`   | 是  | 对话格式的消息列表，用于描述视频内容            |
| `stream`   | `boolean` | 否  | 是否启用流式响应（推荐设置为 `true`）        |

## 调用示例

<CodeGroup>
  ```python Python theme={null}
  import openai

  client = openai.OpenAI(
      api_key="sk-your-api-key-here",
      base_url="https://aiapi.xiaoliu.fun/v1"
  )

  response = client.chat.completions.create(
      model="sora-2",
      messages=[
          {"role": "user", "content": "一只可爱的小猫在草地上奔跑"}
      ],
      stream=True
  )

  for chunk in response:
      if chunk.choices[0].delta.content:
          print(chunk.choices[0].delta.content, end="")
  ```

  ```bash cURL theme={null}
  curl https://api.qhaigc.net/v1/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-your-api-key-here" \
    -d '{
      "model": "sora-2",
      "messages": [
        {"role": "user", "content": "一只可爱的小猫在草地上奔跑"}
      ],
      "stream": true
    }'
  ```
</CodeGroup>

## 响应流程

流式响应会实时返回任务进度，成功后提供视频下载链接：

1. `⌛️ 任务正在队列中，请耐心等待...`
2. `🏃 进度：36.0%`
3. ...
4. `✅ 视频生成成功，[点击这里](https://...) 查看视频~~~`


## OpenAPI

````yaml /api-reference/video/create-videos.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
  description: API 文档，支持绘图、语音生成、视频生成、音乐生成等多种 AIGC 接口。
servers:
  - url: https://aiapi.xiaoliu.fun
    description: 生产服务器
security:
  - bearerAuth: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - 聊天模型
      summary: 对话补全
      description: 使用大语言模型进行对话交互
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: 模型名称
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                      content:
                        type: string
                style:
                  type: string
                  enum:
                    - openai
                    - claude
                    - gemini
                  default: openai
                  description: 接口风格，支持 OpenAI、Claude、Gemini
                stream:
                  type: boolean
                  description: 是否流式
              required:
                - model
                - messages
      responses:
        '200':
          description: 成功响应 (流式)
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````