@runwayml/sdk 3.5.0 → 3.7.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +5 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +5 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +5 -2
  7. package/client.js.map +1 -1
  8. package/client.mjs +5 -2
  9. package/client.mjs.map +1 -1
  10. package/internal/tslib.js +17 -17
  11. package/package.json +1 -1
  12. package/resources/character-performance.d.mts +32 -5
  13. package/resources/character-performance.d.mts.map +1 -1
  14. package/resources/character-performance.d.ts +32 -5
  15. package/resources/character-performance.d.ts.map +1 -1
  16. package/resources/character-performance.js +16 -0
  17. package/resources/character-performance.js.map +1 -1
  18. package/resources/character-performance.mjs +16 -0
  19. package/resources/character-performance.mjs.map +1 -1
  20. package/resources/image-to-video.d.mts +215 -88
  21. package/resources/image-to-video.d.mts.map +1 -1
  22. package/resources/image-to-video.d.ts +215 -88
  23. package/resources/image-to-video.d.ts.map +1 -1
  24. package/resources/image-to-video.js +10 -1
  25. package/resources/image-to-video.js.map +1 -1
  26. package/resources/image-to-video.mjs +10 -1
  27. package/resources/image-to-video.mjs.map +1 -1
  28. package/resources/index.d.mts +1 -0
  29. package/resources/index.d.mts.map +1 -1
  30. package/resources/index.d.ts +1 -0
  31. package/resources/index.d.ts.map +1 -1
  32. package/resources/index.js +3 -1
  33. package/resources/index.js.map +1 -1
  34. package/resources/index.mjs +1 -0
  35. package/resources/index.mjs.map +1 -1
  36. package/resources/speech-to-speech.d.mts +16 -4
  37. package/resources/speech-to-speech.d.mts.map +1 -1
  38. package/resources/speech-to-speech.d.ts +16 -4
  39. package/resources/speech-to-speech.d.ts.map +1 -1
  40. package/resources/text-to-image.d.mts +3 -3
  41. package/resources/text-to-image.d.ts +3 -3
  42. package/resources/text-to-speech.d.mts +2 -2
  43. package/resources/text-to-speech.d.ts +2 -2
  44. package/resources/text-to-video.d.mts +50 -28
  45. package/resources/text-to-video.d.mts.map +1 -1
  46. package/resources/text-to-video.d.ts +50 -28
  47. package/resources/text-to-video.d.ts.map +1 -1
  48. package/resources/uploads.d.mts +33 -0
  49. package/resources/uploads.d.mts.map +1 -0
  50. package/resources/uploads.d.ts +33 -0
  51. package/resources/uploads.d.ts.map +1 -0
  52. package/resources/uploads.js +75 -0
  53. package/resources/uploads.js.map +1 -0
  54. package/resources/uploads.mjs +70 -0
  55. package/resources/uploads.mjs.map +1 -0
  56. package/resources/video-to-video.d.mts +12 -10
  57. package/resources/video-to-video.d.mts.map +1 -1
  58. package/resources/video-to-video.d.ts +12 -10
  59. package/resources/video-to-video.d.ts.map +1 -1
  60. package/resources/video-to-video.js +10 -0
  61. package/resources/video-to-video.js.map +1 -1
  62. package/resources/video-to-video.mjs +10 -0
  63. package/resources/video-to-video.mjs.map +1 -1
  64. package/resources/video-upscale.d.mts +9 -9
  65. package/resources/video-upscale.d.mts.map +1 -1
  66. package/resources/video-upscale.d.ts +9 -9
  67. package/resources/video-upscale.d.ts.map +1 -1
  68. package/resources/video-upscale.js +8 -0
  69. package/resources/video-upscale.js.map +1 -1
  70. package/resources/video-upscale.mjs +8 -0
  71. package/resources/video-upscale.mjs.map +1 -1
  72. package/resources/voice-dubbing.d.mts +10 -1
  73. package/resources/voice-dubbing.d.mts.map +1 -1
  74. package/resources/voice-dubbing.d.ts +10 -1
  75. package/resources/voice-dubbing.d.ts.map +1 -1
  76. package/resources/voice-dubbing.js +9 -0
  77. package/resources/voice-dubbing.js.map +1 -1
  78. package/resources/voice-dubbing.mjs +9 -0
  79. package/resources/voice-dubbing.mjs.map +1 -1
  80. package/resources/voice-isolation.d.mts +11 -2
  81. package/resources/voice-isolation.d.mts.map +1 -1
  82. package/resources/voice-isolation.d.ts +11 -2
  83. package/resources/voice-isolation.d.ts.map +1 -1
  84. package/resources/voice-isolation.js +10 -1
  85. package/resources/voice-isolation.js.map +1 -1
  86. package/resources/voice-isolation.mjs +10 -1
  87. package/resources/voice-isolation.mjs.map +1 -1
  88. package/src/client.ts +11 -2
  89. package/src/resources/character-performance.ts +32 -5
  90. package/src/resources/image-to-video.ts +253 -99
  91. package/src/resources/index.ts +1 -0
  92. package/src/resources/speech-to-speech.ts +16 -4
  93. package/src/resources/text-to-image.ts +3 -3
  94. package/src/resources/text-to-speech.ts +2 -2
  95. package/src/resources/text-to-video.ts +61 -28
  96. package/src/resources/uploads.ts +135 -0
  97. package/src/resources/video-to-video.ts +12 -10
  98. package/src/resources/video-upscale.ts +9 -9
  99. package/src/resources/voice-dubbing.ts +10 -1
  100. package/src/resources/voice-isolation.ts +11 -2
  101. package/src/version.ts +1 -1
  102. package/version.d.mts +1 -1
  103. package/version.d.ts +1 -1
  104. package/version.js +1 -1
  105. package/version.mjs +1 -1
@@ -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
+ }
@@ -7,6 +7,16 @@ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/poll
7
7
  export class VideoToVideo extends APIResource {
8
8
  /**
9
9
  * This endpoint will start a new task to generate a video from a video.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const videoToVideo = await client.videoToVideo.create({
14
+ * model: 'gen4_aleph',
15
+ * promptText: 'x',
16
+ * ratio: '1280:720',
17
+ * videoUri: 'https://example.com/video.mp4',
18
+ * });
19
+ * ```
10
20
  */
11
21
  create(
12
22
  body: VideoToVideoCreateParams,
@@ -19,16 +29,10 @@ export class VideoToVideo extends APIResource {
19
29
  }
20
30
 
21
31
  export interface VideoToVideoCreateResponse {
22
- /**
23
- * The ID of the newly created task.
24
- */
25
32
  id: string;
26
33
  }
27
34
 
28
35
  export interface VideoToVideoCreateParams {
29
- /**
30
- * The model variant to use.
31
- */
32
36
  model: 'gen4_aleph';
33
37
 
34
38
  /**
@@ -43,8 +47,7 @@ export interface VideoToVideoCreateParams {
43
47
  ratio: '1280:720' | '720:1280' | '1104:832' | '960:960' | '832:1104' | '1584:672' | '848:480' | '640:480';
44
48
 
45
49
  /**
46
- * A HTTPS URL pointing to a video or a data URI containing a video. See
47
- * [our docs](/assets/inputs#videos) on video inputs for more information.
50
+ * A HTTPS URL.
48
51
  */
49
52
  videoUri: string;
50
53
 
@@ -87,8 +90,7 @@ export namespace VideoToVideoCreateParams {
87
90
  type: 'image';
88
91
 
89
92
  /**
90
- * A HTTPS URL pointing to an image or a data URI containing an image. See
91
- * [our docs](/assets/inputs#images) on image inputs for more information.
93
+ * A HTTPS URL.
92
94
  */
93
95
  uri: string;
94
96
  }
@@ -8,6 +8,14 @@ export class VideoUpscale extends APIResource {
8
8
  /**
9
9
  * This endpoint will start a new task to upscale a video. Videos will be upscaled
10
10
  * by a factor of 4X, capped at a maximum of 4096px along each side.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const videoUpscale = await client.videoUpscale.create({
15
+ * model: 'upscale_v1',
16
+ * videoUri: 'https://example.com/video.mp4',
17
+ * });
18
+ * ```
11
19
  */
12
20
  create(
13
21
  body: VideoUpscaleCreateParams,
@@ -20,22 +28,14 @@ export class VideoUpscale extends APIResource {
20
28
  }
21
29
 
22
30
  export interface VideoUpscaleCreateResponse {
23
- /**
24
- * The ID of the newly created task.
25
- */
26
31
  id: string;
27
32
  }
28
33
 
29
34
  export interface VideoUpscaleCreateParams {
30
- /**
31
- * The model variant to use.
32
- */
33
35
  model: 'upscale_v1';
34
36
 
35
37
  /**
36
- * A HTTPS URL pointing to a video or a data URI containing a video. The video must
37
- * be less than 4096px on each side. The video duration may not exceed 40 seconds.
38
- * See [our docs](/assets/inputs#videos) on video inputs for more information.
38
+ * A HTTPS URL.
39
39
  */
40
40
  videoUri: string;
41
41
  }
@@ -7,6 +7,15 @@ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/poll
7
7
  export class VoiceDubbing extends APIResource {
8
8
  /**
9
9
  * This endpoint will start a new task to dub audio content to a target language.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const voiceDubbing = await client.voiceDubbing.create({
14
+ * audioUri: 'https://example.com/audio.mp3',
15
+ * model: 'eleven_voice_dubbing',
16
+ * targetLang: 'en',
17
+ * });
18
+ * ```
10
19
  */
11
20
  create(
12
21
  body: VoiceDubbingCreateParams,
@@ -24,7 +33,7 @@ export interface VoiceDubbingCreateResponse {
24
33
 
25
34
  export interface VoiceDubbingCreateParams {
26
35
  /**
27
- * A data URI containing encoded audio.
36
+ * A HTTPS URL.
28
37
  */
29
38
  audioUri: string;
30
39
 
@@ -7,7 +7,16 @@ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/poll
7
7
  export class VoiceIsolation extends APIResource {
8
8
  /**
9
9
  * This endpoint will start a new task to isolate the voice from the background
10
- * audio.
10
+ * audio. Audio duration must be greater than 4.6 seconds and less than 3600
11
+ * seconds.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const voiceIsolation = await client.voiceIsolation.create({
16
+ * audioUri: 'https://example.com/audio.mp3',
17
+ * model: 'eleven_voice_isolation',
18
+ * });
19
+ * ```
11
20
  */
12
21
  create(
13
22
  body: VoiceIsolationCreateParams,
@@ -25,7 +34,7 @@ export interface VoiceIsolationCreateResponse {
25
34
 
26
35
  export interface VoiceIsolationCreateParams {
27
36
  /**
28
- * A data URI containing encoded audio.
37
+ * A HTTPS URL.
29
38
  */
30
39
  audioUri: string;
31
40
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '3.5.0'; // x-release-please-version
1
+ export const VERSION = '3.7.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.5.0";
1
+ export declare const VERSION = "3.7.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.5.0";
1
+ export declare const VERSION = "3.7.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '3.5.0'; // x-release-please-version
4
+ exports.VERSION = '3.7.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.5.0'; // x-release-please-version
1
+ export const VERSION = '3.7.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map