python/resources/videos/methods/create/index.md +0 −243 deleted
File Deleted View Diff
1## Create video
2
3`videos.create(VideoCreateParams**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: str`
12
13 Text prompt that describes the video to generate.
14
15- `input_reference: Optional[InputReference]`
16
17 Optional reference asset upload or reference object that guides generation.
18
19 - `FileTypes`
20
21 Optional reference asset upload or reference object that guides generation.
22
23 - `class ImageInputReferenceParam: …`
24
25 - `file_id: Optional[str]`
26
27 - `image_url: Optional[str]`
28
29 A fully qualified URL or base64-encoded data URL.
30
31- `model: Optional[VideoModelParam]`
32
33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.
34
35 - `str`
36
37 - `Literal["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: Optional[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: Optional[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: str`
78
79 Unique identifier for the video job.
80
81 - `completed_at: Optional[int]`
82
83 Unix timestamp (seconds) for when the job completed, if finished.
84
85 - `created_at: int`
86
87 Unix timestamp (seconds) for when the job was created.
88
89 - `error: Optional[VideoCreateError]`
90
91 Error payload that explains why generation failed, if applicable.
92
93 - `code: str`
94
95 A machine-readable error code that was returned.
96
97 - `message: str`
98
99 A human-readable description of the error that was returned.
100
101 - `expires_at: Optional[int]`
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 - `str`
110
111 - `Literal["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: Literal["video"]`
124
125 The object type, which is always `video`.
126
127 - `"video"`
128
129 - `progress: int`
130
131 Approximate completion percentage for the generation task.
132
133 - `prompt: Optional[str]`
134
135 The prompt that was used to generate the video.
136
137 - `remixed_from_video_id: Optional[str]`
138
139 Identifier of the source video if this video is a remix.
140
141 - `seconds: Union[str, VideoSeconds]`
142
143 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.
144
145 - `str`
146
147 - `Literal["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: Literal["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```python
182import os
183from openai import OpenAI
184
185client = OpenAI(
186 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
187)
188video = client.videos.create(
189 prompt="x",
190)
191print(video.id)
192```
193
194#### Response
195
196```json
197{
198 "id": "id",
199 "completed_at": 0,
200 "created_at": 0,
201 "error": {
202 "code": "code",
203 "message": "message"
204 },
205 "expires_at": 0,
206 "model": "string",
207 "object": "video",
208 "progress": 0,
209 "prompt": "prompt",
210 "remixed_from_video_id": "remixed_from_video_id",
211 "seconds": "string",
212 "size": "720x1280",
213 "status": "queued"
214}
215```
216
217### Example
218
219```python
220from openai import OpenAI
221
222client = OpenAI()
223video = client.videos.create(
224 prompt="A calico cat playing a piano on stage",
225)
226print(video.id)
227```
228
229#### Response
230
231```json
232{
233 "id": "video_123",
234 "object": "video",
235 "model": "sora-2",
236 "status": "queued",
237 "progress": 0,
238 "created_at": 1712697600,
239 "size": "1024x1792",
240 "seconds": "8",
241 "quality": "standard"
242}
243```