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

# Sora 2 sync API quick start (archived)

> Archived quick start for the retired Sora 2 sync API; use Wan 2.7 or Seedance 2.0 for video generation instead.

<Warning>
  **Archived page: the Sora 2 video API has been retired.** LaoZhang API stopped serving Sora 2 on July 1, 2026, and OpenAI removed the Videos API, `sora-2`, and `sora-2-pro` from its API on September 24, 2026. This page keeps the legacy route documentation for existing integrations, and its examples no longer work.

  For video generation, use [Wan 2.7](/en/api-capabilities/wan-video-generation) or [Seedance 2.0](/en/api-capabilities/seedance2-video-generation). To migrate, see [Sora 2 API retired: move to Wan or Seedance](/en/api-capabilities/sora2/official-forward).
</Warning>

This page covers the legacy route's **Sync API** (`/v1/chat/completions`).

## Prerequisites

<Steps>
  <Step title="Get API Key">
    Login to [laozhang.ai console](https://api.laozhang.ai) to get your API key
  </Step>

  <Step title="Configure Billing Mode">
    Edit token settings, choose either billing mode (both have same price):

    * **Usage first** (按量优先, recommended): Uses balance first, auto-switches when low. Suitable for most users
    * **Per-call** (按次计费): Direct charge per call. Suitable for strict budget control

    Both modes had the same historical price of \$0.15 per call (10 s or 15 s); only the billing method differed.

    <img src="https://mintcdn.com/laozhangai-edd05f2c/_loZ0Jy0ZI__xJ9z/images/sora2-token-setting.png?fit=max&auto=format&n=_loZ0Jy0ZI__xJ9z&q=85&s=d54128f51509467d6b73d207bbe5c86f" alt="Token settings" width="1280" height="537" data-path="images/sora2-token-setting.png" />

    Calls failed if no billing mode was set, so this step had to be completed first.
  </Step>
</Steps>

## Text-to-Video Example

<Note>
  **About `@sama` in Examples**

  You may notice `@sama` used in examples. This is OpenAI CEO Sam Altman's authorized ID, allowing his likeness to appear in videos.

  **This is optional**:

  * ✓ Can use `@sama` or other verified IDs
  * ✓ Can skip it and use normal scene descriptions (e.g., "a cat in a garden")
  * ✗ Cannot upload real person photos (will be rejected and charged)

  **Want yourself in the video?** Requires Cameo certification in Sora iOS app. See [FAQ](/en/api-capabilities/sora2/troubleshooting)
</Note>

The simplest usage method - generate videos using only text descriptions.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.laozhang.ai/v1/chat/completions" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "sora_video2",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "A happy cat playing with a ball in a sunny garden"
            }
          ]
        }
      ]
    }'
  ```

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

  client = openai.OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.laozhang.ai/v1"
  )

  response = client.chat.completions.create(
      model="sora_video2",
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "text",
                      "text": "A happy cat playing with a ball in a sunny garden"
                  }
              ]
          }
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```javascript JavaScript theme={null}
  const OpenAI = require('openai');

  const client = new OpenAI({
    apiKey: 'YOUR_API_KEY',
    baseURL: 'https://api.laozhang.ai/v1'
  });

  async function generateVideo() {
    const response = await client.chat.completions.create({
      model: 'sora_video2',
      messages: [
        {
          role: 'user',
          content: [
            {
              type: 'text',
              text: 'A happy cat playing with a ball in a sunny garden'
            }
          ]
        }
      ]
    });

    console.log(response.choices[0].message.content);
  }

  generateVideo();
  ```
</CodeGroup>

## Image-to-Video Example

Supports uploading reference images (up to 1 image), supports both URL and Base64 methods.

<CodeGroup>
  ```bash cURL (URL) theme={null}
  curl -X POST "https://api.laozhang.ai/v1/chat/completions" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "sora_video2",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "Make this character jump off the desk and come to life"
            },
            {
              "type": "image_url",
              "image_url": {
                "url": "https://example.com/images/input.png"
              }
            }
          ]
        }
      ]
    }'
  ```

  ```python Python (URL) theme={null}
  import openai

  client = openai.OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.laozhang.ai/v1"
  )

  response = client.chat.completions.create(
      model="sora_video2",
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "text",
                      "text": "Make this character jump off the desk and come to life"
                  },
                  {
                      "type": "image_url",
                      "image_url": {
                          "url": "https://example.com/images/input.png"
                      }
                  }
              ]
          }
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```bash cURL (Base64) theme={null}
  curl -X POST "https://api.laozhang.ai/v1/chat/completions" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "sora_video2",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "Make this character jump off the desk and come to life"
            },
            {
              "type": "image_url",
              "image_url": {
                "url": "data:image/png;base64,iVBORw0KGgoAAAANS..."
              }
            }
          ]
        }
      ]
    }'
  ```
</CodeGroup>

## Streaming Output Example

Enable streaming output to view generation progress in real-time.

<CodeGroup>
  ```python Python (Streaming) theme={null}
  import openai
  import re

  client = openai.OpenAI(
      api_key="YOUR_API_KEY",
      base_url="https://api.laozhang.ai/v1"
  )

  stream = client.chat.completions.create(
      model="sora_video2",
      messages=[
          {
              "role": "user",
              "content": [
                  {
                      "type": "text",
                      "text": "A cute cat playing with a ball in a sunny garden"
                  }
              ]
          }
      ],
      stream=True
  )

  # Store full content to extract video link
  full_content = ""

  print("Generation progress:\n")
  for chunk in stream:
      if chunk.choices[0].delta.content:
          content = chunk.choices[0].delta.content
          print(content, end='', flush=True)
          full_content += content

  print("\n")

  # Extract video link
  video_url_match = re.search(r'https://[^\s\)]+\.mp4', full_content)
  if video_url_match:
      video_url = video_url_match.group(0)
      print(f"\n✅ Video link: {video_url}")
      print("⚠️  Video valid for 1 day, download immediately!")
  else:
      print("\n❌ Video link not found, generation may have failed")
  ```

  ```javascript JavaScript (Streaming) theme={null}
  const OpenAI = require('openai');

  const client = new OpenAI({
    apiKey: 'YOUR_API_KEY',
    baseURL: 'https://api.laozhang.ai/v1'
  });

  async function generateVideoStream() {
    const stream = await client.chat.completions.create({
      model: 'sora_video2',
      messages: [
        {
          role: 'user',
          content: [
            {
              type: 'text',
              text: 'A cute cat playing with a ball in a sunny garden'
            }
          ]
        }
      ],
      stream: true
    });

    for await (const chunk of stream) {
      if (chunk.choices[0]?.delta?.content) {
        process.stdout.write(chunk.choices[0].delta.content);
      }
    }
  }

  generateVideoStream();
  ```
</CodeGroup>

## Output Interpretation

### Streaming Output Format

When `"stream": true` is enabled, API returns SSE (Server-Sent Events) format:

````text theme={null}
data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{"content":"```json\n{\n    \"prompt\": \"A happy cat playing with a ball in a sunny garden\",\n    \"mode\": \"Vertical Mode\"\n}\n```\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{"content":"> ⌛️ Task is in queue, please wait patiently...\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{"content":"> 🏃 Progress: 36.0%\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{"content":"> ✅ Video generated successfully, [Click here](https://example.com/sora/video.mp4) to view video~~~\n\n"},"finish_reason":null}]}

data: {"id":"foaicmpl-xxx","object":"chat.completion.chunk","created":1759759480,"model":"sora_video2","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":17,"completion_tokens":244,"total_tokens":261}}

data: [DONE]
````

### Key Field Descriptions

* `choices[0].delta.content`: Contains progress information or final video link
* `finish_reason`: When `"stop"`, generation is complete
* `usage`: Last message contains token usage
* Video link: Provided as Markdown link in success message

### Generation Time

* **Queue Wait:** Depends on peak hours
* **Video Generation:** About 2-3 minutes (for 10-second video)
* **Total:** 2-5 minutes on average

## Next Steps

<CardGroup cols={2}>
  <Card title="Sora 2 API retired" icon="shield-check" href="/en/api-capabilities/sora2/official-forward">
    Move to Wan 2.7 or Seedance 2.0
  </Card>

  <Card title="API Reference" icon="book" href="/en/api-capabilities/sora2/api-reference">
    View legacy API documentation
  </Card>

  <Card title="Code Examples" icon="code" href="/en/api-capabilities/sora2/examples">
    View more usage examples
  </Card>

  <Card title="FAQ" icon="circle-question-mark" href="/en/api-capabilities/sora2/troubleshooting">
    Common issues and solutions
  </Card>
</CardGroup>

## Important Notes

<Warning>
  **Remember to download videos immediately!**

  Generated video URLs are valid for only **1 day**. Please download to local storage after generation to avoid losing videos.
</Warning>

Model selection:

* `sora_video2`: Vertical screen (704×1280), suitable for mobile viewing
* `sora_video2-landscape`: Horizontal screen (1280×704), suitable for widescreen displays


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.