Repository navigation
Expand file tree
/
Copy pathvideos.ts
More file actions
233 lines (196 loc) · 5.58 KB
/
Copy pathvideos.ts
File metadata and controls
233 lines (196 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { ConversationCursorPage, type ConversationCursorPageParams, PagePromise } from '../core/pagination';
import { type Uploadable } from '../core/uploads';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { maybeMultipartFormRequestOptions } from '../internal/uploads';
import { path } from '../internal/utils/path';
export class Videos extends APIResource {
/**
* Create a video
*/
create(body: VideoCreateParams, options?: RequestOptions): APIPromise<Video> {
return this._client.post('/videos', maybeMultipartFormRequestOptions({ body, ...options }, this._client));
}
/**
* Retrieve a video
*/
retrieve(videoID: string, options?: RequestOptions): APIPromise<Video> {
return this._client.get(path`/videos/${videoID}`, options);
}
/**
* List videos
*/
list(
query: VideoListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<VideosPage, Video> {
return this._client.getAPIList('/videos', ConversationCursorPage<Video>, { query, ...options });
}
/**
* Delete a video
*/
delete(videoID: string, options?: RequestOptions): APIPromise<VideoDeleteResponse> {
return this._client.delete(path`/videos/${videoID}`, options);
}
/**
* Download video content
*/
downloadContent(
videoID: string,
query: VideoDownloadContentParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<Response> {
return this._client.get(path`/videos/${videoID}/content`, {
query,
...options,
headers: buildHeaders([{ Accept: 'application/binary' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Create a video remix
*/
remix(videoID: string, body: VideoRemixParams, options?: RequestOptions): APIPromise<Video> {
return this._client.post(
path`/videos/${videoID}/remix`,
maybeMultipartFormRequestOptions({ body, ...options }, this._client),
);
}
}
export type VideosPage = ConversationCursorPage<Video>;
/**
* Structured information describing a generated video job.
*/
export interface Video {
/**
* Unique identifier for the video job.
*/
id: string;
/**
* Unix timestamp (seconds) for when the job completed, if finished.
*/
completed_at: number | null;
/**
* Unix timestamp (seconds) for when the job was created.
*/
created_at: number;
/**
* Error payload that explains why generation failed, if applicable.
*/
error: VideoCreateError | null;
/**
* Unix timestamp (seconds) for when the downloadable assets expire, if set.
*/
expires_at: number | null;
/**
* The video generation model that produced the job.
*/
model: VideoModel;
/**
* The object type, which is always `video`.
*/
object: 'video';
/**
* Approximate completion percentage for the generation task.
*/
progress: number;
/**
* Identifier of the source video if this video is a remix.
*/
remixed_from_video_id: string | null;
/**
* Duration of the generated clip in seconds.
*/
seconds: VideoSeconds;
/**
* The resolution of the generated video.
*/
size: VideoSize;
/**
* Current lifecycle status of the video job.
*/
status: 'queued' | 'in_progress' | 'completed' | 'failed';
}
export interface VideoCreateError {
code: string;
message: string;
}
export type VideoModel = 'sora-2' | 'sora-2-pro';
export type VideoSeconds = '4' | '8' | '12';
export type VideoSize = '720x1280' | '1280x720' | '1024x1792' | '1792x1024';
/**
* Confirmation payload returned after deleting a video.
*/
export interface VideoDeleteResponse {
/**
* Identifier of the deleted video.
*/
id: string;
/**
* Indicates that the video resource was deleted.
*/
deleted: boolean;
/**
* The object type that signals the deletion response.
*/
object: 'video.deleted';
}
export interface VideoCreateParams {
/**
* Text prompt that describes the video to generate.
*/
prompt: string;
/**
* Optional image reference that guides generation.
*/
input_reference?: Uploadable;
/**
* The video generation model to use. Defaults to `sora-2`.
*/
model?: VideoModel;
/**
* Clip duration in seconds. Defaults to 4 seconds.
*/
seconds?: VideoSeconds;
/**
* Output resolution formatted as width x height. Defaults to 720x1280.
*/
size?: VideoSize;
}
export interface VideoListParams extends ConversationCursorPageParams {
/**
* Sort order of results by timestamp. Use `asc` for ascending order or `desc` for
* descending order.
*/
order?: 'asc' | 'desc';
}
export interface VideoDownloadContentParams {
/**
* Which downloadable asset to return. Defaults to the MP4 video.
*/
variant?: 'video' | 'thumbnail' | 'spritesheet';
}
export interface VideoRemixParams {
/**
* Updated text prompt that directs the remix generation.
*/
prompt: string;
}
export declare namespace Videos {
export {
type Video as Video,
type VideoCreateError as VideoCreateError,
type VideoModel as VideoModel,
type VideoSeconds as VideoSeconds,
type VideoSize as VideoSize,
type VideoDeleteResponse as VideoDeleteResponse,
type VideosPage as VideosPage,
type VideoCreateParams as VideoCreateParams,
type VideoListParams as VideoListParams,
type VideoDownloadContentParams as VideoDownloadContentParams,
type VideoRemixParams as VideoRemixParams,
};
}