ruby/resources/videos/methods/create/index.md +0 −240 deleted
File Deleted View Diff
1## Create video
2
3`videos.create(**kwargs) -> Video`
4
5**post** `/videos`
6
7Create a new video generation job from a prompt and optional reference assets.
8
9### Parameters
10
11- `prompt: String`
12
13 Text prompt that describes the video to generate.
14
15- `input_reference: String | ImageInputReferenceParam`
16
17 Optional reference asset upload or reference object that guides generation.
18
19 - `String = String`
20
21 Optional reference asset upload or reference object that guides generation.
22
23 - `class ImageInputReferenceParam`
24
25 - `file_id: String`
26
27 - `image_url: String`
28
29 A fully qualified URL or base64-encoded data URL.
30
31- `model: VideoModel`
32
33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.
34
35 - `String = String`
36
37 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`
38
39 - `:"sora-2"`
40
41 - `:"sora-2-pro"`
42
43 - `:"sora-2-2025-10-06"`
44
45 - `:"sora-2-pro-2025-10-06"`
46
47 - `:"sora-2-2025-12-08"`
48
49- `seconds: VideoSeconds`
50
51 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.
52
53 - `:"4"`
54
55 - `:"8"`
56
57 - `:"12"`
58
59- `size: VideoSize`
60
61 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.
62
63 - `:"720x1280"`
64
65 - `:"1280x720"`
66
67 - `:"1024x1792"`
68
69 - `:"1792x1024"`
70
71### Returns
72
73- `class Video`
74
75 Structured information describing a generated video job.
76
77 - `id: String`
78
79 Unique identifier for the video job.
80
81 - `completed_at: Integer`
82
83 Unix timestamp (seconds) for when the job completed, if finished.
84
85 - `created_at: Integer`
86
87 Unix timestamp (seconds) for when the job was created.
88
89 - `error: VideoCreateError`
90
91 Error payload that explains why generation failed, if applicable.
92
93 - `code: String`
94
95 A machine-readable error code that was returned.
96
97 - `message: String`
98
99 A human-readable description of the error that was returned.
100
101 - `expires_at: Integer`
102
103 Unix timestamp (seconds) for when the downloadable assets expire, if set.
104
105 - `model: VideoModel`
106
107 The video generation model that produced the job.
108
109 - `String = String`
110
111 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`
112
113 - `:"sora-2"`
114
115 - `:"sora-2-pro"`
116
117 - `:"sora-2-2025-10-06"`
118
119 - `:"sora-2-pro-2025-10-06"`
120
121 - `:"sora-2-2025-12-08"`
122
123 - `object: :video`
124
125 The object type, which is always `video`.
126
127 - `:video`
128
129 - `progress: Integer`
130
131 Approximate completion percentage for the generation task.
132
133 - `prompt: String`
134
135 The prompt that was used to generate the video.
136
137 - `remixed_from_video_id: String`
138
139 Identifier of the source video if this video is a remix.
140
141 - `seconds: String | VideoSeconds`
142
143 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.
144
145 - `String = String`
146
147 - `VideoSeconds = :"4" | :"8" | :"12"`
148
149 - `:"4"`
150
151 - `:"8"`
152
153 - `:"12"`
154
155 - `size: VideoSize`
156
157 The resolution of the generated video.
158
159 - `:"720x1280"`
160
161 - `:"1280x720"`
162
163 - `:"1024x1792"`
164
165 - `:"1792x1024"`
166
167 - `status: :queued | :in_progress | :completed | :failed`
168
169 Current lifecycle status of the video job.
170
171 - `:queued`
172
173 - `:in_progress`
174
175 - `:completed`
176
177 - `:failed`
178
179### Example
180
181```ruby
182require "openai"
183
184openai = OpenAI::Client.new(api_key: "My API Key")
185
186video = openai.videos.create(prompt: "x")
187
188puts(video)
189```
190
191#### Response
192
193```json
194{
195 "id": "id",
196 "completed_at": 0,
197 "created_at": 0,
198 "error": {
199 "code": "code",
200 "message": "message"
201 },
202 "expires_at": 0,
203 "model": "string",
204 "object": "video",
205 "progress": 0,
206 "prompt": "prompt",
207 "remixed_from_video_id": "remixed_from_video_id",
208 "seconds": "string",
209 "size": "720x1280",
210 "status": "queued"
211}
212```
213
214### Example
215
216```ruby
217require "openai"
218
219openai = OpenAI::Client.new
220
221video = openai.videos.create(prompt: "A calico cat playing a piano on stage")
222
223puts(video)
224```
225
226#### Response
227
228```json
229{
230 "id": "video_123",
231 "object": "video",
232 "model": "sora-2",
233 "status": "queued",
234 "progress": 0,
235 "created_at": 1712697600,
236 "size": "1024x1792",
237 "seconds": "8",
238 "quality": "standard"
239}
240```