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