Create video
client.Videos.New(ctx, body) (*Video, error)
post /videos
Create a new video generation job from a prompt and optional reference assets.
Parameters
-
body VideoNewParams-
Prompt param.Field[string]Text prompt that describes the video to generate.
-
InputReference param.Field[VideoNewParamsInputReferenceUnion]Optional reference asset upload or reference object that guides generation.
-
Reader -
type ImageInputReferenceParamResp struct{…}-
FileID string -
ImageURL stringA fully qualified URL or base64-encoded data URL.
-
-
-
Model param.Field[VideoModel]The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to
sora-2. -
Seconds param.Field[VideoSeconds]Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.
-
Size param.Field[VideoSize]Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.
-
Returns
-
type Video struct{…}Structured information describing a generated video job.
-
ID stringUnique identifier for the video job.
-
CompletedAt int64Unix timestamp (seconds) for when the job completed, if finished.
-
CreatedAt int64Unix timestamp (seconds) for when the job was created.
-
Error VideoCreateErrorError payload that explains why generation failed, if applicable.
-
Code stringA machine-readable error code that was returned.
-
Message stringA human-readable description of the error that was returned.
-
-
ExpiresAt int64Unix timestamp (seconds) for when the downloadable assets expire, if set.
-
Model VideoModelThe video generation model that produced the job.
-
string -
type VideoModel string-
const VideoModelSora2 VideoModel = "sora-2" -
const VideoModelSora2Pro VideoModel = "sora-2-pro" -
const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06" -
const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06" -
const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"
-
-
-
Object VideoThe object type, which is always
video.const VideoVideo Video = "video"
-
Progress int64Approximate completion percentage for the generation task.
-
Prompt stringThe prompt that was used to generate the video.
-
RemixedFromVideoID stringIdentifier of the source video if this video is a remix.
-
Seconds VideoSecondsDuration of the generated clip in seconds. For extensions, this is the stitched total duration.
-
string -
type VideoSeconds string-
const VideoSeconds4 VideoSeconds = "4" -
const VideoSeconds8 VideoSeconds = "8" -
const VideoSeconds12 VideoSeconds = "12"
-
-
-
Size VideoSizeThe resolution of the generated video.
-
const VideoSize720x1280 VideoSize = "720x1280" -
const VideoSize1280x720 VideoSize = "1280x720" -
const VideoSize1024x1792 VideoSize = "1024x1792" -
const VideoSize1792x1024 VideoSize = "1792x1024"
-
-
Status VideoStatusCurrent lifecycle status of the video job.
-
const VideoStatusQueued VideoStatus = "queued" -
const VideoStatusInProgress VideoStatus = "in_progress" -
const VideoStatusCompleted VideoStatus = "completed" -
const VideoStatusFailed VideoStatus = "failed"
-
-
Example
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
video, err := client.Videos.New(context.TODO(), openai.VideoNewParams{
Prompt: "x",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", video.ID)
}
Response
{
"id": "id",
"completed_at": 0,
"created_at": 0,
"error": {
"code": "code",
"message": "message"
},
"expires_at": 0,
"model": "sora-2",
"object": "video",
"progress": 0,
"prompt": "prompt",
"remixed_from_video_id": "remixed_from_video_id",
"seconds": "4",
"size": "720x1280",
"status": "queued"
}
Example
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)
}
Response
{
"id": "video_123",
"object": "video",
"model": "sora-2",
"status": "queued",
"progress": 0,
"created_at": 1712697600,
"size": "1024x1792",
"seconds": "8",
"quality": "standard"
}