@runwayml/sdk 3.6.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/client.d.mts +5 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +5 -2
- package/client.d.ts.map +1 -1
- package/client.js +5 -2
- package/client.js.map +1 -1
- package/client.mjs +5 -2
- package/client.mjs.map +1 -1
- package/internal/tslib.js +17 -17
- package/package.json +1 -1
- package/resources/image-to-video.d.mts +45 -37
- package/resources/image-to-video.d.mts.map +1 -1
- package/resources/image-to-video.d.ts +45 -37
- package/resources/image-to-video.d.ts.map +1 -1
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/speech-to-speech.d.mts +1 -1
- package/resources/speech-to-speech.d.ts +1 -1
- package/resources/text-to-image.d.mts +111 -90
- package/resources/text-to-image.d.mts.map +1 -1
- package/resources/text-to-image.d.ts +111 -90
- package/resources/text-to-image.d.ts.map +1 -1
- package/resources/text-to-video.d.mts +8 -0
- package/resources/text-to-video.d.mts.map +1 -1
- package/resources/text-to-video.d.ts +8 -0
- package/resources/text-to-video.d.ts.map +1 -1
- package/resources/uploads.d.mts +33 -0
- package/resources/uploads.d.mts.map +1 -0
- package/resources/uploads.d.ts +33 -0
- package/resources/uploads.d.ts.map +1 -0
- package/resources/uploads.js +75 -0
- package/resources/uploads.js.map +1 -0
- package/resources/uploads.mjs +70 -0
- package/resources/uploads.mjs.map +1 -0
- package/src/client.ts +11 -2
- package/src/resources/image-to-video.ts +54 -44
- package/src/resources/index.ts +1 -0
- package/src/resources/speech-to-speech.ts +1 -1
- package/src/resources/text-to-image.ts +173 -116
- package/src/resources/text-to-video.ts +10 -0
- package/src/resources/uploads.ts +135 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -33,8 +33,8 @@ export interface ImageToVideoCreateResponse {
|
|
|
33
33
|
|
|
34
34
|
export type ImageToVideoCreateParams =
|
|
35
35
|
| ImageToVideoCreateParams.Gen4Turbo
|
|
36
|
-
| ImageToVideoCreateParams.Gen3aTurbo
|
|
37
36
|
| ImageToVideoCreateParams.Veo3_1
|
|
37
|
+
| ImageToVideoCreateParams.Gen3aTurbo
|
|
38
38
|
| ImageToVideoCreateParams.Veo3_1Fast
|
|
39
39
|
| ImageToVideoCreateParams.Veo3;
|
|
40
40
|
|
|
@@ -102,6 +102,54 @@ export declare namespace ImageToVideoCreateParams {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
export interface Veo3_1 {
|
|
106
|
+
model: 'veo3.1';
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* You may specify an image to use as the first frame of the output video, or an
|
|
110
|
+
* array with a first frame and optionally a last frame. This model does not
|
|
111
|
+
* support generating with only a last frame.
|
|
112
|
+
*/
|
|
113
|
+
promptImage: string | Array<Veo3_1.PromptImage>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The resolution of the output video.
|
|
117
|
+
*/
|
|
118
|
+
ratio: '1280:720' | '720:1280' | '1080:1920' | '1920:1080';
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Whether to generate audio for the video. Audio inclusion affects pricing.
|
|
122
|
+
*/
|
|
123
|
+
audio?: boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The number of seconds of duration for the output video.
|
|
127
|
+
*/
|
|
128
|
+
duration?: 4 | 6 | 8;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A non-empty string up to 1000 characters (measured in UTF-16 code units). This
|
|
132
|
+
* should describe in detail what should appear in the output.
|
|
133
|
+
*/
|
|
134
|
+
promptText?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export namespace Veo3_1 {
|
|
138
|
+
export interface PromptImage {
|
|
139
|
+
/**
|
|
140
|
+
* The position of the image in the output video. "first" will use the image as the
|
|
141
|
+
* first frame of the video, "last" will use the image as the last frame of the
|
|
142
|
+
* video.
|
|
143
|
+
*/
|
|
144
|
+
position: 'first' | 'last';
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A HTTPS URL.
|
|
148
|
+
*/
|
|
149
|
+
uri: string;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
105
153
|
export interface Gen3aTurbo {
|
|
106
154
|
model: 'gen3a_turbo';
|
|
107
155
|
|
|
@@ -166,49 +214,6 @@ export declare namespace ImageToVideoCreateParams {
|
|
|
166
214
|
}
|
|
167
215
|
}
|
|
168
216
|
|
|
169
|
-
export interface Veo3_1 {
|
|
170
|
-
model: 'veo3.1';
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* You may specify an image to use as the first frame of the output video, or an
|
|
174
|
-
* array with a first frame and optionally a last frame. This model does not
|
|
175
|
-
* support generating with only a last frame.
|
|
176
|
-
*/
|
|
177
|
-
promptImage: string | Array<Veo3_1.PromptImage>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* The resolution of the output video.
|
|
181
|
-
*/
|
|
182
|
-
ratio: '1280:720' | '720:1280' | '1080:1920' | '1920:1080';
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The number of seconds of duration for the output video.
|
|
186
|
-
*/
|
|
187
|
-
duration?: 4 | 6 | 8;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* A non-empty string up to 1000 characters (measured in UTF-16 code units). This
|
|
191
|
-
* should describe in detail what should appear in the output.
|
|
192
|
-
*/
|
|
193
|
-
promptText?: string;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export namespace Veo3_1 {
|
|
197
|
-
export interface PromptImage {
|
|
198
|
-
/**
|
|
199
|
-
* The position of the image in the output video. "first" will use the image as the
|
|
200
|
-
* first frame of the video, "last" will use the image as the last frame of the
|
|
201
|
-
* video.
|
|
202
|
-
*/
|
|
203
|
-
position: 'first' | 'last';
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* A HTTPS URL.
|
|
207
|
-
*/
|
|
208
|
-
uri: string;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
217
|
export interface Veo3_1Fast {
|
|
213
218
|
model: 'veo3.1_fast';
|
|
214
219
|
|
|
@@ -224,6 +229,11 @@ export declare namespace ImageToVideoCreateParams {
|
|
|
224
229
|
*/
|
|
225
230
|
ratio: '1280:720' | '720:1280' | '1080:1920' | '1920:1080';
|
|
226
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Whether to generate audio for the video. Audio inclusion affects pricing.
|
|
234
|
+
*/
|
|
235
|
+
audio?: boolean;
|
|
236
|
+
|
|
227
237
|
/**
|
|
228
238
|
* The number of seconds of duration for the output video.
|
|
229
239
|
*/
|
package/src/resources/index.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface SpeechToSpeechCreateResponse {
|
|
|
24
24
|
|
|
25
25
|
export interface SpeechToSpeechCreateParams {
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* An audio file containing dialogue to be processed.
|
|
28
28
|
*/
|
|
29
29
|
media: SpeechToSpeechCreateParams.Audio | SpeechToSpeechCreateParams.Video;
|
|
30
30
|
|
|
@@ -19,140 +19,197 @@ export class TextToImage extends APIResource {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface TextToImageCreateResponse {
|
|
22
|
-
/**
|
|
23
|
-
* The ID of the newly created task.
|
|
24
|
-
*/
|
|
25
22
|
id: string;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
model: 'gen4_image_turbo' | 'gen4_image' | 'gemini_2.5_flash';
|
|
25
|
+
export type TextToImageCreateParams =
|
|
26
|
+
| TextToImageCreateParams.Gen4ImageTurbo
|
|
27
|
+
| TextToImageCreateParams.Gen4Image
|
|
28
|
+
| TextToImageCreateParams.Gemini2_5Flash;
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
promptText: string;
|
|
30
|
+
export declare namespace TextToImageCreateParams {
|
|
31
|
+
export interface Gen4ImageTurbo {
|
|
32
|
+
model: 'gen4_image_turbo';
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* - `1920:1080`
|
|
46
|
-
* - `1080:1920`
|
|
47
|
-
* - `1024:1024`
|
|
48
|
-
* - `1360:768`
|
|
49
|
-
* - `1080:1080`
|
|
50
|
-
* - `1168:880`
|
|
51
|
-
* - `1440:1080`
|
|
52
|
-
* - `1080:1440`
|
|
53
|
-
* - `1808:768`
|
|
54
|
-
* - `2112:912`
|
|
55
|
-
* - `1280:720`
|
|
56
|
-
* - `720:1280`
|
|
57
|
-
* - `720:720`
|
|
58
|
-
* - `960:720`
|
|
59
|
-
* - `720:960`
|
|
60
|
-
* - `1680:720`
|
|
61
|
-
*
|
|
62
|
-
* `gemini_2.5_flash` supports the following values:
|
|
63
|
-
*
|
|
64
|
-
* - `1344:768`
|
|
65
|
-
* - `768:1344`
|
|
66
|
-
* - `1024:1024`
|
|
67
|
-
* - `1184:864`
|
|
68
|
-
* - `864:1184`
|
|
69
|
-
* - `1536:672`
|
|
70
|
-
* - `832x1248`
|
|
71
|
-
* - `1248x832`
|
|
72
|
-
* - `896x1152`
|
|
73
|
-
* - `1152x896`
|
|
74
|
-
*/
|
|
75
|
-
ratio:
|
|
76
|
-
| '1920:1080'
|
|
77
|
-
| '1080:1920'
|
|
78
|
-
| '1024:1024'
|
|
79
|
-
| '1360:768'
|
|
80
|
-
| '1080:1080'
|
|
81
|
-
| '1168:880'
|
|
82
|
-
| '1440:1080'
|
|
83
|
-
| '1080:1440'
|
|
84
|
-
| '1808:768'
|
|
85
|
-
| '2112:912'
|
|
86
|
-
| '1280:720'
|
|
87
|
-
| '720:1280'
|
|
88
|
-
| '720:720'
|
|
89
|
-
| '960:720'
|
|
90
|
-
| '720:960'
|
|
91
|
-
| '1680:720'
|
|
92
|
-
| '1344:768'
|
|
93
|
-
| '768:1344'
|
|
94
|
-
| '1184:864'
|
|
95
|
-
| '864:1184'
|
|
96
|
-
| '1536:672'
|
|
97
|
-
| '832x1248'
|
|
98
|
-
| '1248x832'
|
|
99
|
-
| '896x1152'
|
|
100
|
-
| '1152x896';
|
|
34
|
+
/**
|
|
35
|
+
* A non-empty string up to 1000 characters (measured in UTF-16 code units). This
|
|
36
|
+
* should describe in detail what should appear in the output.
|
|
37
|
+
*/
|
|
38
|
+
promptText: string;
|
|
101
39
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The resolution of the output image.
|
|
42
|
+
*/
|
|
43
|
+
ratio:
|
|
44
|
+
| '1024:1024'
|
|
45
|
+
| '1080:1080'
|
|
46
|
+
| '1168:880'
|
|
47
|
+
| '1360:768'
|
|
48
|
+
| '1440:1080'
|
|
49
|
+
| '1080:1440'
|
|
50
|
+
| '1808:768'
|
|
51
|
+
| '1920:1080'
|
|
52
|
+
| '1080:1920'
|
|
53
|
+
| '2112:912'
|
|
54
|
+
| '1280:720'
|
|
55
|
+
| '720:1280'
|
|
56
|
+
| '720:720'
|
|
57
|
+
| '960:720'
|
|
58
|
+
| '720:960'
|
|
59
|
+
| '1680:720';
|
|
109
60
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*/
|
|
116
|
-
referenceImages?: Array<TextToImageCreateParams.ReferenceImage>;
|
|
61
|
+
/**
|
|
62
|
+
* An array of one to three images to be used as references for the generated image
|
|
63
|
+
* output.
|
|
64
|
+
*/
|
|
65
|
+
referenceImages: Array<Gen4ImageTurbo.ReferenceImage>;
|
|
117
66
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*/
|
|
123
|
-
seed?: number;
|
|
124
|
-
}
|
|
67
|
+
/**
|
|
68
|
+
* Settings that affect the behavior of the content moderation system.
|
|
69
|
+
*/
|
|
70
|
+
contentModeration?: Gen4ImageTurbo.ContentModeration;
|
|
125
71
|
|
|
126
|
-
export namespace TextToImageCreateParams {
|
|
127
|
-
/**
|
|
128
|
-
* Settings that affect the behavior of the content moderation system.
|
|
129
|
-
*
|
|
130
|
-
* This field is allowed only for the following model variants: `gen4_image_turbo`,
|
|
131
|
-
* `gen4_image`
|
|
132
|
-
*/
|
|
133
|
-
export interface ContentModeration {
|
|
134
72
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
73
|
+
* If unspecified, a random number is chosen. Varying the seed integer is a way to
|
|
74
|
+
* get different results for the same other request parameters. Using the same seed
|
|
75
|
+
* integer for an identical request will produce similar results.
|
|
137
76
|
*/
|
|
138
|
-
|
|
77
|
+
seed?: number;
|
|
139
78
|
}
|
|
140
79
|
|
|
141
|
-
export
|
|
80
|
+
export namespace Gen4ImageTurbo {
|
|
81
|
+
export interface ReferenceImage {
|
|
82
|
+
/**
|
|
83
|
+
* A HTTPS URL.
|
|
84
|
+
*/
|
|
85
|
+
uri: string;
|
|
86
|
+
|
|
87
|
+
tag?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
142
90
|
/**
|
|
143
|
-
*
|
|
144
|
-
* the generated output image. See [our docs](/assets/inputs#images) on image
|
|
145
|
-
* inputs for more information.
|
|
91
|
+
* Settings that affect the behavior of the content moderation system.
|
|
146
92
|
*/
|
|
147
|
-
|
|
93
|
+
export interface ContentModeration {
|
|
94
|
+
/**
|
|
95
|
+
* When set to `low`, the content moderation system will be less strict about
|
|
96
|
+
* preventing generations that include recognizable public figures.
|
|
97
|
+
*/
|
|
98
|
+
publicFigureThreshold?: 'auto' | 'low';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface Gen4Image {
|
|
103
|
+
model: 'gen4_image';
|
|
148
104
|
|
|
149
105
|
/**
|
|
150
|
-
* A
|
|
151
|
-
*
|
|
152
|
-
* refer to the reference image's tag in the prompt text with at-mention syntax:
|
|
153
|
-
* `@tag`. Tags are case-sensitive.
|
|
106
|
+
* A non-empty string up to 1000 characters (measured in UTF-16 code units). This
|
|
107
|
+
* should describe in detail what should appear in the output.
|
|
154
108
|
*/
|
|
155
|
-
|
|
109
|
+
promptText: string;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The resolution of the output image.
|
|
113
|
+
*/
|
|
114
|
+
ratio:
|
|
115
|
+
| '1024:1024'
|
|
116
|
+
| '1080:1080'
|
|
117
|
+
| '1168:880'
|
|
118
|
+
| '1360:768'
|
|
119
|
+
| '1440:1080'
|
|
120
|
+
| '1080:1440'
|
|
121
|
+
| '1808:768'
|
|
122
|
+
| '1920:1080'
|
|
123
|
+
| '1080:1920'
|
|
124
|
+
| '2112:912'
|
|
125
|
+
| '1280:720'
|
|
126
|
+
| '720:1280'
|
|
127
|
+
| '720:720'
|
|
128
|
+
| '960:720'
|
|
129
|
+
| '720:960'
|
|
130
|
+
| '1680:720';
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Settings that affect the behavior of the content moderation system.
|
|
134
|
+
*/
|
|
135
|
+
contentModeration?: Gen4Image.ContentModeration;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* An array of up to three images to be used as references for the generated image
|
|
139
|
+
* output.
|
|
140
|
+
*/
|
|
141
|
+
referenceImages?: Array<Gen4Image.ReferenceImage>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* If unspecified, a random number is chosen. Varying the seed integer is a way to
|
|
145
|
+
* get different results for the same other request parameters. Using the same seed
|
|
146
|
+
* integer for an identical request will produce similar results.
|
|
147
|
+
*/
|
|
148
|
+
seed?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export namespace Gen4Image {
|
|
152
|
+
/**
|
|
153
|
+
* Settings that affect the behavior of the content moderation system.
|
|
154
|
+
*/
|
|
155
|
+
export interface ContentModeration {
|
|
156
|
+
/**
|
|
157
|
+
* When set to `low`, the content moderation system will be less strict about
|
|
158
|
+
* preventing generations that include recognizable public figures.
|
|
159
|
+
*/
|
|
160
|
+
publicFigureThreshold?: 'auto' | 'low';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface ReferenceImage {
|
|
164
|
+
/**
|
|
165
|
+
* A HTTPS URL.
|
|
166
|
+
*/
|
|
167
|
+
uri: string;
|
|
168
|
+
|
|
169
|
+
tag?: string;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface Gemini2_5Flash {
|
|
174
|
+
model: 'gemini_2.5_flash';
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A non-empty string up to 1000 characters (measured in UTF-16 code units). This
|
|
178
|
+
* should describe in detail what should appear in the output.
|
|
179
|
+
*/
|
|
180
|
+
promptText: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The resolution of the output image.
|
|
184
|
+
*/
|
|
185
|
+
ratio:
|
|
186
|
+
| '1344:768'
|
|
187
|
+
| '768:1344'
|
|
188
|
+
| '1024:1024'
|
|
189
|
+
| '1184:864'
|
|
190
|
+
| '864:1184'
|
|
191
|
+
| '1536:672'
|
|
192
|
+
| '832:1248'
|
|
193
|
+
| '1248:832'
|
|
194
|
+
| '896:1152'
|
|
195
|
+
| '1152:896';
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* An array of up to three images to be used as references for the generated image
|
|
199
|
+
* output.
|
|
200
|
+
*/
|
|
201
|
+
referenceImages?: Array<Gemini2_5Flash.ReferenceImage>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export namespace Gemini2_5Flash {
|
|
205
|
+
export interface ReferenceImage {
|
|
206
|
+
/**
|
|
207
|
+
* A HTTPS URL.
|
|
208
|
+
*/
|
|
209
|
+
uri: string;
|
|
210
|
+
|
|
211
|
+
tag?: string;
|
|
212
|
+
}
|
|
156
213
|
}
|
|
157
214
|
}
|
|
158
215
|
|
|
@@ -42,6 +42,11 @@ export declare namespace TextToVideoCreateParams {
|
|
|
42
42
|
*/
|
|
43
43
|
ratio: '1280:720' | '720:1280' | '1080:1920' | '1920:1080';
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Whether to generate audio for the video. Audio inclusion affects pricing.
|
|
47
|
+
*/
|
|
48
|
+
audio?: boolean;
|
|
49
|
+
|
|
45
50
|
/**
|
|
46
51
|
* The number of seconds of duration for the output video.
|
|
47
52
|
*/
|
|
@@ -62,6 +67,11 @@ export declare namespace TextToVideoCreateParams {
|
|
|
62
67
|
*/
|
|
63
68
|
ratio: '1280:720' | '720:1280' | '1080:1920' | '1920:1080';
|
|
64
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Whether to generate audio for the video. Audio inclusion affects pricing.
|
|
72
|
+
*/
|
|
73
|
+
audio?: boolean;
|
|
74
|
+
|
|
65
75
|
/**
|
|
66
76
|
* The number of seconds of duration for the output video.
|
|
67
77
|
*/
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import { RequestOptions } from '../internal/request-options';
|
|
5
|
+
import { Uploadable } from '../internal/uploads';
|
|
6
|
+
import { toFile } from '../internal/to-file';
|
|
7
|
+
import type { Fetch } from '../internal/builtin-types';
|
|
8
|
+
import * as Errors from '../core/error';
|
|
9
|
+
import { castToError } from '../internal/errors';
|
|
10
|
+
|
|
11
|
+
interface RunwayUploadStartedResponse {
|
|
12
|
+
runwayUri: string;
|
|
13
|
+
uploadUrl: string;
|
|
14
|
+
fields: Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function uploadFileToStorage(
|
|
18
|
+
uploadUrl: string,
|
|
19
|
+
fields: Record<string, string>,
|
|
20
|
+
file: File,
|
|
21
|
+
fileMetadata: string | undefined,
|
|
22
|
+
timeout: number | undefined,
|
|
23
|
+
fetch: Fetch,
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
const formData = new FormData();
|
|
26
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
27
|
+
formData.append(key, value);
|
|
28
|
+
}
|
|
29
|
+
if (fileMetadata !== undefined) {
|
|
30
|
+
formData.append('metadata', fileMetadata);
|
|
31
|
+
}
|
|
32
|
+
formData.append('file', file);
|
|
33
|
+
|
|
34
|
+
const controller = new AbortController();
|
|
35
|
+
const timeoutId = timeout ? setTimeout(() => controller.abort(), timeout) : undefined;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(uploadUrl, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: formData,
|
|
41
|
+
signal: controller.signal,
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const errorText = await response.text().catch(() => '');
|
|
45
|
+
throw new Errors.APIError(
|
|
46
|
+
response.status,
|
|
47
|
+
{ error: errorText },
|
|
48
|
+
`Upload failed with status ${response.status}`,
|
|
49
|
+
response.headers,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error instanceof Errors.APIError) {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
const err = castToError(error);
|
|
57
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
58
|
+
throw new Errors.APIConnectionTimeoutError();
|
|
59
|
+
}
|
|
60
|
+
throw new Errors.APIConnectionError({ cause: err });
|
|
61
|
+
} finally {
|
|
62
|
+
if (timeoutId) {
|
|
63
|
+
clearTimeout(timeoutId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class Uploads extends APIResource {
|
|
69
|
+
/**
|
|
70
|
+
* Uploads a temporary media file that can be used in other API generation
|
|
71
|
+
* requests.
|
|
72
|
+
*
|
|
73
|
+
* The uploaded files will be automatically expired and deleted after a
|
|
74
|
+
* period of time.
|
|
75
|
+
*/
|
|
76
|
+
async createEphemeral(
|
|
77
|
+
params: UploadsCreateEphemeralParams,
|
|
78
|
+
options?: RequestOptions,
|
|
79
|
+
): Promise<UploadCreateEphemeralResponse> {
|
|
80
|
+
const { file, fileMetadata } = params;
|
|
81
|
+
const fileObj = await toFile(file);
|
|
82
|
+
|
|
83
|
+
if (!fileObj.name || fileObj.name === 'unknown_file') {
|
|
84
|
+
throw new Error(
|
|
85
|
+
'Cannot infer filename from file. Please provide a File with a name property, ' +
|
|
86
|
+
'or use the toFile() utility with a name parameter to convert your data to a File.',
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const placeholder = await this._client.post<RunwayUploadStartedResponse>('/v1/uploads', {
|
|
91
|
+
body: { filename: fileObj.name, type: 'ephemeral' as const },
|
|
92
|
+
...options,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const timeout = options?.timeout ?? this._client.timeout;
|
|
96
|
+
// Access private fetch - using type assertion as it's needed for direct upload
|
|
97
|
+
const fetch = (this._client as unknown as { fetch: Fetch }).fetch;
|
|
98
|
+
await uploadFileToStorage(
|
|
99
|
+
placeholder.uploadUrl,
|
|
100
|
+
placeholder.fields,
|
|
101
|
+
fileObj,
|
|
102
|
+
fileMetadata,
|
|
103
|
+
timeout,
|
|
104
|
+
fetch,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return { uri: placeholder.runwayUri };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface UploadCreateEphemeralResponse {
|
|
112
|
+
/**
|
|
113
|
+
* The Runway upload URI to use in other API generation requests.
|
|
114
|
+
*/
|
|
115
|
+
uri: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface UploadsCreateEphemeralParams {
|
|
119
|
+
/**
|
|
120
|
+
* The file to upload. Must be a supported media type (image, video, or audio).
|
|
121
|
+
*/
|
|
122
|
+
file: Uploadable;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Optional metadata for the file, serialized as a field in multipart/form-data.
|
|
126
|
+
*/
|
|
127
|
+
fileMetadata?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare namespace Uploads {
|
|
131
|
+
export {
|
|
132
|
+
type UploadCreateEphemeralResponse as UploadCreateEphemeralResponse,
|
|
133
|
+
type UploadsCreateEphemeralParams as UploadsCreateEphemeralParams,
|
|
134
|
+
};
|
|
135
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '3.
|
|
1
|
+
export const VERSION = '3.8.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.
|
|
1
|
+
export declare const VERSION = "3.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.
|
|
1
|
+
export const VERSION = '3.8.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|