Create video
videos.create(**kwargs) -> Video
post /videos
Create a new video generation job from a prompt and optional reference assets.
Parameters
-
prompt: StringText prompt that describes the video to generate.
-
input_reference: String | ImageInputReferenceParamOptional reference asset upload or reference object that guides generation.
-
String = StringOptional reference asset upload or reference object that guides generation.
-
class ImageInputReferenceParam-
file_id: String -
image_url: StringA fully qualified URL or base64-encoded data URL.
-
-
-
model: VideoModelThe video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to
sora-2.-
String = String -
VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more-
:"sora-2" -
:"sora-2-pro" -
:"sora-2-2025-10-06" -
:"sora-2-pro-2025-10-06" -
:"sora-2-2025-12-08"
-
-
-
seconds: VideoSecondsClip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.
-
:"4" -
:"8" -
:"12"
-
-
size: VideoSizeOutput resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.
-
:"720x1280" -
:"1280x720" -
:"1024x1792" -
:"1792x1024"
-
Returns
-
class VideoStructured information describing a generated video job.
-
id: StringUnique identifier for the video job.
-
completed_at: IntegerUnix timestamp (seconds) for when the job completed, if finished.
-
created_at: IntegerUnix 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.
-
-
expires_at: IntegerUnix timestamp (seconds) for when the downloadable assets expire, if set.
-
model: VideoModelThe video generation model that produced the job.
-
String = String -
VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more-
:"sora-2" -
:"sora-2-pro" -
:"sora-2-2025-10-06" -
:"sora-2-pro-2025-10-06" -
:"sora-2-2025-12-08"
-
-
-
object: :videoThe object type, which is always
video.:video
-
progress: IntegerApproximate completion percentage for the generation task.
-
prompt: StringThe prompt that was used to generate the video.
-
remixed_from_video_id: StringIdentifier of the source video if this video is a remix.
-
seconds: String | VideoSecondsDuration of the generated clip in seconds. For extensions, this is the stitched total duration.
-
String = String -
VideoSeconds = :"4" | :"8" | :"12"-
:"4" -
:"8" -
:"12"
-
-
-
size: VideoSizeThe resolution of the generated video.
-
:"720x1280" -
:"1280x720" -
:"1024x1792" -
:"1792x1024"
-
-
status: :queued | :in_progress | :completed | :failedCurrent lifecycle status of the video job.
-
:queued -
:in_progress -
:completed -
:failed
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
video = openai.videos.create(prompt: "x")
puts(video)
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
require "openai"
openai = OpenAI::Client.new
video = openai.videos.create(prompt: "A calico cat playing a piano on stage")
puts(video)
Response
{
"id": "video_123",
"object": "video",
"model": "sora-2",
"status": "queued",
"progress": 0,
"created_at": 1712697600,
"size": "1024x1792",
"seconds": "8",
"quality": "standard"
}