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