跳转到主要内容
Send a POST request to https://api.qhaigc.net/v1/chat/completions to generate a video using OpenAI’s Sora 2 model. Describe the scene you want in a chat message, choose between standard (sora-2) or high-definition (sora-2-hd) quality, and enable streaming to receive real-time progress updates. When generation is complete, the response includes a link to your video.
Video generation is computationally intensive and typically takes 120 seconds or more. Enable streaming ("stream": true) so you can monitor progress rather than waiting for a single blocking response.

Request

POST https://api.qhaigc.net/v1/chat/completions

Parameters

model
string
必填
The video generation model. Use "sora-2" for standard quality or "sora-2-hd" for high definition.
messages
array
必填
A list of chat-style message objects describing the video content. Set "role" to "user" and provide your scene description in "content".
stream
boolean
Whether to stream progress updates. Set to true (recommended) to receive incremental status messages as the video is generated.

Response

When stream is true, the endpoint returns a sequence of server-sent events (SSE) that report progress and, on completion, provide the video download URL. The streaming response follows this pattern:
  1. ⌛️ 任务正在队列中,请耐心等待... — Task queued
  2. 🏃 进度:36.0% — Generation in progress
  3. ✅ 视频生成成功,[点击这里](...) 查看视频~~~ — Complete with video link

Code examples

import openai

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

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

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

Models

ModelDescription
sora-2Standard quality. Faster generation, lower cost.
sora-2-hdHigh definition. Higher resolution output.
  • Model list — Full list of available video generation models and pricing