Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Create video

client.Videos.New(ctx, body) (*Video, error)
POST/videos

Create a new video generation job from a prompt and optional reference assets.

ParametersExpand Collapse
body VideoNewParams
Prompt param.Field[string]

Text prompt that describes the video to generate.

minLength1
maxLength32000
InputReference param.Field[VideoNewParamsInputReferenceUnion]Optional

Optional reference asset upload or reference object that guides generation.

Model param.Field[VideoModel]Optional

The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to sora-2.

Seconds param.Field[VideoSeconds]Optional

Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

Size param.Field[VideoSize]Optional

Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

ReturnsExpand Collapse
type Video struct{…}

Structured information describing a generated video job.

ID string

Unique identifier for the video job.

CompletedAt int64

Unix timestamp (seconds) for when the job completed, if finished.

formatunixtime
CreatedAt int64

Unix timestamp (seconds) for when the job was created.

formatunixtime

Error payload that explains why generation failed, if applicable.

ExpiresAt int64

Unix timestamp (seconds) for when the downloadable assets expire, if set.

formatunixtime
Model VideoModel

The video generation model that produced the job.

Object Video

The object type, which is always video.

Progress int64

Approximate completion percentage for the generation task.

Prompt string

The prompt that was used to generate the video.

RemixedFromVideoID string

Identifier of the source video if this video is a remix.

Seconds VideoSeconds

Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

The resolution of the generated video.

Status VideoStatus

Current lifecycle status of the video job.

Create video

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
)

func main() {
  client := openai.NewClient()
  video, err := client.Videos.New(context.TODO(), openai.VideoNewParams{
    Prompt: "A calico cat playing a piano on stage",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", video.ID)
}
{
  "id": "video_123",
  "object": "video",
  "model": "sora-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1712697600,
  "size": "1024x1792",
  "seconds": "8",
  "quality": "standard"
}
Returns Examples
{
  "id": "video_123",
  "object": "video",
  "model": "sora-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1712697600,
  "size": "1024x1792",
  "seconds": "8",
  "quality": "standard"
}