@runwayml/sdk 2.2.1 → 2.4.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 (71) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/core.d.ts +5 -2
  3. package/core.d.ts.map +1 -1
  4. package/core.js +11 -6
  5. package/core.js.map +1 -1
  6. package/core.mjs +11 -6
  7. package/core.mjs.map +1 -1
  8. package/index.d.mts +5 -0
  9. package/index.d.ts +5 -0
  10. package/index.d.ts.map +1 -1
  11. package/index.js +14 -3
  12. package/index.js.map +1 -1
  13. package/index.mjs +10 -2
  14. package/index.mjs.map +1 -1
  15. package/lib/polling.d.ts +49 -0
  16. package/lib/polling.d.ts.map +1 -0
  17. package/lib/polling.js +67 -0
  18. package/lib/polling.js.map +1 -0
  19. package/lib/polling.mjs +60 -0
  20. package/lib/polling.mjs.map +1 -0
  21. package/package.json +1 -1
  22. package/resource.d.ts +1 -1
  23. package/resource.d.ts.map +1 -1
  24. package/resource.js.map +1 -1
  25. package/resource.mjs.map +1 -1
  26. package/resources/image-to-video.d.ts +17 -2
  27. package/resources/image-to-video.d.ts.map +1 -1
  28. package/resources/image-to-video.js +2 -1
  29. package/resources/image-to-video.js.map +1 -1
  30. package/resources/image-to-video.mjs +2 -1
  31. package/resources/image-to-video.mjs.map +1 -1
  32. package/resources/index.d.ts +1 -0
  33. package/resources/index.d.ts.map +1 -1
  34. package/resources/index.js +3 -1
  35. package/resources/index.js.map +1 -1
  36. package/resources/index.mjs +1 -0
  37. package/resources/index.mjs.map +1 -1
  38. package/resources/organization.d.ts +30 -0
  39. package/resources/organization.d.ts.map +1 -1
  40. package/resources/tasks.d.ts +2 -1
  41. package/resources/tasks.d.ts.map +1 -1
  42. package/resources/tasks.js +2 -1
  43. package/resources/tasks.js.map +1 -1
  44. package/resources/tasks.mjs +2 -1
  45. package/resources/tasks.mjs.map +1 -1
  46. package/resources/text-to-image.d.ts +2 -1
  47. package/resources/text-to-image.d.ts.map +1 -1
  48. package/resources/text-to-image.js +2 -1
  49. package/resources/text-to-image.js.map +1 -1
  50. package/resources/text-to-image.mjs +2 -1
  51. package/resources/text-to-image.mjs.map +1 -1
  52. package/resources/video-upscale.d.ts +32 -0
  53. package/resources/video-upscale.d.ts.map +1 -0
  54. package/resources/video-upscale.js +17 -0
  55. package/resources/video-upscale.js.map +1 -0
  56. package/resources/video-upscale.mjs +13 -0
  57. package/resources/video-upscale.mjs.map +1 -0
  58. package/src/core.ts +11 -4
  59. package/src/index.ts +23 -0
  60. package/src/lib/polling.ts +109 -0
  61. package/src/resource.ts +1 -1
  62. package/src/resources/image-to-video.ts +22 -3
  63. package/src/resources/index.ts +5 -0
  64. package/src/resources/organization.ts +35 -0
  65. package/src/resources/tasks.ts +6 -2
  66. package/src/resources/text-to-image.ts +5 -2
  67. package/src/resources/video-upscale.ts +48 -0
  68. package/src/version.ts +1 -1
  69. package/version.d.ts +1 -1
  70. package/version.js +1 -1
  71. package/version.mjs +1 -1
@@ -3,13 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Tasks = void 0;
5
5
  const resource_1 = require("../resource.js");
6
+ const polling_1 = require("../lib/polling.js");
6
7
  class Tasks extends resource_1.APIResource {
7
8
  /**
8
9
  * Return details about a task. Consumers of this API should not expect updates
9
10
  * more frequent than once every five seconds for a given task.
10
11
  */
11
12
  retrieve(id, options) {
12
- return this._client.get(`/v1/tasks/${id}`, options);
13
+ return (0, polling_1.wrapAsWaitableResource)(this._client)(this._client.get(`/v1/tasks/${id}`, options), true);
13
14
  }
14
15
  /**
15
16
  * Tasks that are running, pending, or throttled can be canceled by invoking this
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../src/resources/tasks.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAG1C,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AAvBD,sBAuBC"}
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../src/resources/tasks.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAE1C,+CAAqF;AAErF,MAAa,KAAM,SAAQ,sBAAW;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAA,gCAAsB,EAAuB,IAAI,CAAC,OAAO,CAAC,CAC/D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,sBA0BC"}
@@ -1,12 +1,13 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from "../resource.mjs";
3
+ import { wrapAsWaitableResource } from "../lib/polling.mjs";
3
4
  export class Tasks extends APIResource {
4
5
  /**
5
6
  * Return details about a task. Consumers of this API should not expect updates
6
7
  * more frequent than once every five seconds for a given task.
7
8
  */
8
9
  retrieve(id, options) {
9
- return this._client.get(`/v1/tasks/${id}`, options);
10
+ return wrapAsWaitableResource(this._client)(this._client.get(`/v1/tasks/${id}`, options), true);
10
11
  }
11
12
  /**
12
13
  * Tasks that are running, pending, or throttled can be canceled by invoking this
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.mjs","sourceRoot":"","sources":["../src/resources/tasks.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAGtB,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"tasks.mjs","sourceRoot":"","sources":["../src/resources/tasks.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAA+B,sBAAsB,EAAE;AAE9D,MAAM,OAAO,KAAM,SAAQ,WAAW;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,sBAAsB,CAAuB,IAAI,CAAC,OAAO,CAAC,CAC/D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,EAAE,OAAO,CAAC,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,EAAU,EAAE,OAA6B;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,EAAE;YAC5C,GAAG,OAAO;YACV,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE;SAChD,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,10 +1,11 @@
1
1
  import { APIResource } from "../resource.js";
2
2
  import * as Core from "../core.js";
3
+ import { APIPromiseWithAwaitableTask } from "../lib/polling.js";
3
4
  export declare class TextToImage extends APIResource {
4
5
  /**
5
6
  * This endpoint will start a new task to generate images from text.
6
7
  */
7
- create(body: TextToImageCreateParams, options?: Core.RequestOptions): Core.APIPromise<TextToImageCreateResponse>;
8
+ create(body: TextToImageCreateParams, options?: Core.RequestOptions): APIPromiseWithAwaitableTask<TextToImageCreateResponse>;
8
9
  }
9
10
  export interface TextToImageCreateResponse {
10
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"text-to-image.d.ts","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC;CAG9C;AAED,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EACD,WAAW,GACX,WAAW,GACX,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,CAAC;IAEf;;OAEG;IACH,iBAAiB,CAAC,EAAE,uBAAuB,CAAC,iBAAiB,CAAC;IAE9D;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAEhE;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,uBAAuB,CAAC;IACvC;;OAEG;IACH,UAAiB,iBAAiB;QAChC;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KACxC;IAED,UAAiB,cAAc;QAC7B;;;;WAIG;QACH,GAAG,EAAE,MAAM,CAAC;QAEZ;;;;;WAKG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,uBAAuB,IAAI,uBAAuB,GACxD,CAAC;CACH"}
1
+ {"version":3,"file":"text-to-image.d.ts","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAA0B,MAAM,gBAAgB,CAAC;AAErF,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,2BAA2B,CAAC,yBAAyB,CAAC;CAK1D;AAED,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EACD,WAAW,GACX,WAAW,GACX,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,GACT,UAAU,CAAC;IAEf;;OAEG;IACH,iBAAiB,CAAC,EAAE,uBAAuB,CAAC,iBAAiB,CAAC;IAE9D;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC;IAEhE;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,uBAAuB,CAAC;IACvC;;OAEG;IACH,UAAiB,iBAAiB;QAChC;;;WAGG;QACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KACxC;IAED,UAAiB,cAAc;QAC7B;;;;WAIG;QACH,GAAG,EAAE,MAAM,CAAC;QAEZ;;;;;WAKG;QACH,GAAG,CAAC,EAAE,MAAM,CAAC;KACd;CACF;AAED,MAAM,CAAC,OAAO,WAAW,WAAW,CAAC;IACnC,OAAO,EACL,KAAK,yBAAyB,IAAI,yBAAyB,EAC3D,KAAK,uBAAuB,IAAI,uBAAuB,GACxD,CAAC;CACH"}
@@ -3,12 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.TextToImage = void 0;
5
5
  const resource_1 = require("../resource.js");
6
+ const polling_1 = require("../lib/polling.js");
6
7
  class TextToImage extends resource_1.APIResource {
7
8
  /**
8
9
  * This endpoint will start a new task to generate images from text.
9
10
  */
10
11
  create(body, options) {
11
- return this._client.post('/v1/text_to_image', { body, ...options });
12
+ return (0, polling_1.wrapAsWaitableResource)(this._client)(this._client.post('/v1/text_to_image', { body, ...options }));
12
13
  }
13
14
  }
14
15
  exports.TextToImage = TextToImage;
@@ -1 +1 @@
1
- {"version":3,"file":"text-to-image.js","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAG1C,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAA6B,EAC7B,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AAVD,kCAUC"}
1
+ {"version":3,"file":"text-to-image.js","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAE1C,+CAAqF;AAErF,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAA6B,EAC7B,OAA6B;QAE7B,OAAO,IAAA,gCAAsB,EAA4B,IAAI,CAAC,OAAO,CAAC,CACpE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAC7D,CAAC;IACJ,CAAC;CACF;AAZD,kCAYC"}
@@ -1,11 +1,12 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from "../resource.mjs";
3
+ import { wrapAsWaitableResource } from "../lib/polling.mjs";
3
4
  export class TextToImage extends APIResource {
4
5
  /**
5
6
  * This endpoint will start a new task to generate images from text.
6
7
  */
7
8
  create(body, options) {
8
- return this._client.post('/v1/text_to_image', { body, ...options });
9
+ return wrapAsWaitableResource(this._client)(this._client.post('/v1/text_to_image', { body, ...options }));
9
10
  }
10
11
  }
11
12
  //# sourceMappingURL=text-to-image.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"text-to-image.mjs","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAGtB,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAA6B,EAC7B,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF"}
1
+ {"version":3,"file":"text-to-image.mjs","sourceRoot":"","sources":["../src/resources/text-to-image.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAA+B,sBAAsB,EAAE;AAE9D,MAAM,OAAO,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAA6B,EAC7B,OAA6B;QAE7B,OAAO,sBAAsB,CAA4B,IAAI,CAAC,OAAO,CAAC,CACpE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAC7D,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ import { APIResource } from "../resource.js";
2
+ import * as Core from "../core.js";
3
+ import { APIPromiseWithAwaitableTask } from "../lib/polling.js";
4
+ export declare class VideoUpscale extends APIResource {
5
+ /**
6
+ * This endpoint will start a new task to upscale a video. Videos will be upscaled
7
+ * by a factor of 4X, capped at a maximum of 4096px along each side.
8
+ */
9
+ create(body: VideoUpscaleCreateParams, options?: Core.RequestOptions): APIPromiseWithAwaitableTask<VideoUpscaleCreateResponse>;
10
+ }
11
+ export interface VideoUpscaleCreateResponse {
12
+ /**
13
+ * The ID of the newly created task.
14
+ */
15
+ id: string;
16
+ }
17
+ export interface VideoUpscaleCreateParams {
18
+ /**
19
+ * The model variant to use.
20
+ */
21
+ model: 'upscale_v1';
22
+ /**
23
+ * A HTTPS URL pointing to a video or a data URI containing a video. The video must
24
+ * be less than 4096px on each side. The video duration may not exceed 40 seconds.
25
+ * See [our docs](/assets/inputs#videos) on video inputs for more information.
26
+ */
27
+ videoUri: string;
28
+ }
29
+ export declare namespace VideoUpscale {
30
+ export { type VideoUpscaleCreateResponse as VideoUpscaleCreateResponse, type VideoUpscaleCreateParams as VideoUpscaleCreateParams, };
31
+ }
32
+ //# sourceMappingURL=video-upscale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-upscale.d.ts","sourceRoot":"","sources":["../src/resources/video-upscale.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAA0B,MAAM,gBAAgB,CAAC;AAErF,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;;OAGG;IACH,MAAM,CACJ,IAAI,EAAE,wBAAwB,EAC9B,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,2BAA2B,CAAC,0BAA0B,CAAC;CAK3D;AAED,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IAEpB;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,OAAO,EACL,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,wBAAwB,IAAI,wBAAwB,GAC1D,CAAC;CACH"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.VideoUpscale = void 0;
5
+ const resource_1 = require("../resource.js");
6
+ const polling_1 = require("../lib/polling.js");
7
+ class VideoUpscale extends resource_1.APIResource {
8
+ /**
9
+ * This endpoint will start a new task to upscale a video. Videos will be upscaled
10
+ * by a factor of 4X, capped at a maximum of 4096px along each side.
11
+ */
12
+ create(body, options) {
13
+ return (0, polling_1.wrapAsWaitableResource)(this._client)(this._client.post('/v1/video_upscale', { body, ...options }));
14
+ }
15
+ }
16
+ exports.VideoUpscale = VideoUpscale;
17
+ //# sourceMappingURL=video-upscale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-upscale.js","sourceRoot":"","sources":["../src/resources/video-upscale.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,6CAA0C;AAE1C,+CAAqF;AAErF,MAAa,YAAa,SAAQ,sBAAW;IAC3C;;;OAGG;IACH,MAAM,CACJ,IAA8B,EAC9B,OAA6B;QAE7B,OAAO,IAAA,gCAAsB,EAA6B,IAAI,CAAC,OAAO,CAAC,CACrE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAC7D,CAAC;IACJ,CAAC;CACF;AAbD,oCAaC"}
@@ -0,0 +1,13 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../resource.mjs";
3
+ import { wrapAsWaitableResource } from "../lib/polling.mjs";
4
+ export class VideoUpscale extends APIResource {
5
+ /**
6
+ * This endpoint will start a new task to upscale a video. Videos will be upscaled
7
+ * by a factor of 4X, capped at a maximum of 4096px along each side.
8
+ */
9
+ create(body, options) {
10
+ return wrapAsWaitableResource(this._client)(this._client.post('/v1/video_upscale', { body, ...options }));
11
+ }
12
+ }
13
+ //# sourceMappingURL=video-upscale.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-upscale.mjs","sourceRoot":"","sources":["../src/resources/video-upscale.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAEf,EAA+B,sBAAsB,EAAE;AAE9D,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;;OAGG;IACH,MAAM,CACJ,IAA8B,EAC9B,OAA6B;QAE7B,OAAO,sBAAsB,CAA6B,IAAI,CAAC,OAAO,CAAC,CACrE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAC7D,CAAC;IACJ,CAAC;CACF"}
package/src/core.ts CHANGED
@@ -170,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
170
170
 
171
171
  export abstract class APIClient {
172
172
  baseURL: string;
173
+ #baseURLOverridden: boolean;
173
174
  maxRetries: number;
174
175
  timeout: number;
175
176
  httpAgent: Agent | undefined;
@@ -179,18 +180,21 @@ export abstract class APIClient {
179
180
 
180
181
  constructor({
181
182
  baseURL,
183
+ baseURLOverridden,
182
184
  maxRetries = 2,
183
185
  timeout = 60000, // 1 minute
184
186
  httpAgent,
185
187
  fetch: overriddenFetch,
186
188
  }: {
187
189
  baseURL: string;
190
+ baseURLOverridden: boolean;
188
191
  maxRetries?: number | undefined;
189
192
  timeout: number | undefined;
190
193
  httpAgent: Agent | undefined;
191
194
  fetch: Fetch | undefined;
192
195
  }) {
193
196
  this.baseURL = baseURL;
197
+ this.#baseURLOverridden = baseURLOverridden;
194
198
  this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
195
199
  this.timeout = validatePositiveInteger('timeout', timeout);
196
200
  this.httpAgent = httpAgent;
@@ -300,7 +304,7 @@ export abstract class APIClient {
300
304
  { retryCount = 0 }: { retryCount?: number } = {},
301
305
  ): { req: RequestInit; url: string; timeout: number } {
302
306
  const options = { ...inputOptions };
303
- const { method, path, query, headers: headers = {} } = options;
307
+ const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
304
308
 
305
309
  const body =
306
310
  ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
@@ -310,7 +314,7 @@ export abstract class APIClient {
310
314
  : null;
311
315
  const contentLength = this.calculateContentLength(body);
312
316
 
313
- const url = this.buildURL(path!, query);
317
+ const url = this.buildURL(path!, query, defaultBaseURL);
314
318
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
315
319
  options.timeout = options.timeout ?? this.timeout;
316
320
  const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
@@ -503,11 +507,12 @@ export abstract class APIClient {
503
507
  return new PagePromise<PageClass, Item>(this, request, Page);
504
508
  }
505
509
 
506
- buildURL<Req>(path: string, query: Req | null | undefined): string {
510
+ buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
511
+ const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
507
512
  const url =
508
513
  isAbsoluteURL(path) ?
509
514
  new URL(path)
510
- : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
515
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
511
516
 
512
517
  const defaultQuery = this.defaultQuery();
513
518
  if (!isEmptyObj(defaultQuery)) {
@@ -792,6 +797,7 @@ export type RequestOptions<
792
797
  query?: Req | undefined;
793
798
  body?: Req | null | undefined;
794
799
  headers?: Headers | undefined;
800
+ defaultBaseURL?: string | undefined;
795
801
 
796
802
  maxRetries?: number;
797
803
  stream?: boolean | undefined;
@@ -813,6 +819,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
813
819
  query: true,
814
820
  body: true,
815
821
  headers: true,
822
+ defaultBaseURL: true,
816
823
 
817
824
  maxRetries: true,
818
825
  stream: true,
package/src/index.ts CHANGED
@@ -13,6 +13,11 @@ import {
13
13
  import { Organization, OrganizationRetrieveResponse } from './resources/organization';
14
14
  import { TaskRetrieveResponse, Tasks } from './resources/tasks';
15
15
  import { TextToImage, TextToImageCreateParams, TextToImageCreateResponse } from './resources/text-to-image';
16
+ import {
17
+ VideoUpscale,
18
+ VideoUpscaleCreateParams,
19
+ VideoUpscaleCreateResponse,
20
+ } from './resources/video-upscale';
16
21
 
17
22
  export interface ClientOptions {
18
23
  /**
@@ -128,6 +133,7 @@ export class RunwayML extends Core.APIClient {
128
133
 
129
134
  super({
130
135
  baseURL: options.baseURL!,
136
+ baseURLOverridden: baseURL ? baseURL !== 'https://api.dev.runwayml.com' : false,
131
137
  timeout: options.timeout ?? 60000 /* 1 minute */,
132
138
  httpAgent: options.httpAgent,
133
139
  maxRetries: options.maxRetries,
@@ -143,8 +149,16 @@ export class RunwayML extends Core.APIClient {
143
149
  tasks: API.Tasks = new API.Tasks(this);
144
150
  imageToVideo: API.ImageToVideo = new API.ImageToVideo(this);
145
151
  textToImage: API.TextToImage = new API.TextToImage(this);
152
+ videoUpscale: API.VideoUpscale = new API.VideoUpscale(this);
146
153
  organization: API.Organization = new API.Organization(this);
147
154
 
155
+ /**
156
+ * Check whether the base URL is set to its default.
157
+ */
158
+ #baseURLOverridden(): boolean {
159
+ return this.baseURL !== 'https://api.dev.runwayml.com';
160
+ }
161
+
148
162
  protected override defaultQuery(): Core.DefaultQuery | undefined {
149
163
  return this._options.defaultQuery;
150
164
  }
@@ -185,6 +199,7 @@ export class RunwayML extends Core.APIClient {
185
199
  RunwayML.Tasks = Tasks;
186
200
  RunwayML.ImageToVideo = ImageToVideo;
187
201
  RunwayML.TextToImage = TextToImage;
202
+ RunwayML.VideoUpscale = VideoUpscale;
188
203
  RunwayML.Organization = Organization;
189
204
  export declare namespace RunwayML {
190
205
  export type RequestOptions = Core.RequestOptions;
@@ -203,6 +218,12 @@ export declare namespace RunwayML {
203
218
  type TextToImageCreateParams as TextToImageCreateParams,
204
219
  };
205
220
 
221
+ export {
222
+ VideoUpscale as VideoUpscale,
223
+ type VideoUpscaleCreateResponse as VideoUpscaleCreateResponse,
224
+ type VideoUpscaleCreateParams as VideoUpscaleCreateParams,
225
+ };
226
+
206
227
  export { Organization as Organization, type OrganizationRetrieveResponse as OrganizationRetrieveResponse };
207
228
  }
208
229
 
@@ -223,4 +244,6 @@ export {
223
244
  UnprocessableEntityError,
224
245
  } from './error';
225
246
 
247
+ export { TaskFailedError, TaskTimedOutError, WaitForTaskOutputOptions, AbortError } from './lib/polling';
248
+
226
249
  export default RunwayML;
@@ -0,0 +1,109 @@
1
+ import type { RunwayML } from '../index';
2
+ import * as Core from '../core';
3
+ import { TaskRetrieveResponse } from '../resources/tasks';
4
+
5
+ const POLL_TIME = 6000; // 6 seconds
6
+ const POLL_JITTER = 3000; // 3 seconds
7
+
8
+ export class TaskFailedError extends Error {
9
+ taskDetails: TaskRetrieveResponse;
10
+ constructor(taskDetails: TaskRetrieveResponse) {
11
+ super(taskDetails.failure!);
12
+ this.taskDetails = taskDetails;
13
+ this.name = 'TaskFailedError';
14
+ }
15
+ }
16
+
17
+ export class TaskTimedOutError extends Error {
18
+ taskDetails: TaskRetrieveResponse;
19
+ constructor(taskDetails: TaskRetrieveResponse) {
20
+ super('Task timed out');
21
+ this.taskDetails = taskDetails;
22
+ this.name = 'TaskTimedOutError';
23
+ }
24
+ }
25
+
26
+ export interface WaitForTaskOutputOptions {
27
+ /**
28
+ * The maximum amount of time to wait for the task to complete in milliseconds. If not
29
+ * specified, the default timeout is 10 minutes. Will raise a `TaskTimeoutError` if the
30
+ * task does not complete within the timeout. Setting this to `null` will wait
31
+ * indefinitely (disabling the timeout). Disabling the timeout is not recommended.
32
+ * as it may cause your server to experience issues if your Runway API organization
33
+ * reaches its concurrency limit or if Runway experiences an outage.
34
+ */
35
+ timeout?: number | null;
36
+
37
+ /**
38
+ * Passing an `AbortSignal` allows you to stop waiting for the task to complete.
39
+ * If you are using `waitForTaskOutput` in the handler for an incoming request,
40
+ * `waitForTaskOutput` will not stop polling if the client connection is closed.
41
+ * Passing an `AbortSignal` safely stops polling, preventing memory leaks and
42
+ * ensuring you do not create too many requests to the Runway API.
43
+ */
44
+ abortSignal?: AbortSignal;
45
+ }
46
+
47
+ export class AbortError extends Error {
48
+ code = 22;
49
+ constructor() {
50
+ super('Polling aborted');
51
+ this.name = 'AbortError';
52
+ }
53
+ }
54
+
55
+ export type APIPromiseWithAwaitableTask<T extends { id: string }> = Core.APIPromise<T> & {
56
+ /**
57
+ * When called, this will wait until the task is complete.
58
+ *
59
+ * If the task fails or is cancelled, a `TaskFailedError` will be thrown.
60
+ */
61
+ waitForTaskOutput: (options?: WaitForTaskOutputOptions) => Promise<TaskRetrieveResponse>;
62
+ };
63
+
64
+ export function wrapAsWaitableResource<T extends { id: string }>(client: RunwayML) {
65
+ return (
66
+ responsePromise: Core.APIPromise<T>,
67
+ skipInitialWait: boolean = false,
68
+ ): APIPromiseWithAwaitableTask<T> => {
69
+ return Object.defineProperty(responsePromise, 'waitForTaskOutput', {
70
+ value: async (options?: WaitForTaskOutputOptions) => {
71
+ const wait = () =>
72
+ new Promise<void>((resolve) =>
73
+ setTimeout(resolve, POLL_TIME + Math.random() * POLL_JITTER - POLL_JITTER / 2),
74
+ );
75
+
76
+ if (!skipInitialWait) {
77
+ await wait();
78
+ }
79
+
80
+ const { timeout = 60 * 10 * 1000 } = options ?? {};
81
+ const output = await responsePromise;
82
+ const startTime = Date.now();
83
+ let taskDetails: TaskRetrieveResponse;
84
+ do {
85
+ if (options?.abortSignal?.aborted) {
86
+ throw new AbortError();
87
+ }
88
+ taskDetails = await client.tasks.retrieve(output.id);
89
+ if (taskDetails.status === 'SUCCEEDED') {
90
+ return taskDetails;
91
+ }
92
+ if (taskDetails.status === 'FAILED' || taskDetails.status === 'CANCELLED') {
93
+ throw new TaskFailedError(taskDetails);
94
+ }
95
+ await wait();
96
+ if (timeout != null && Date.now() - startTime > timeout && !options?.abortSignal?.aborted) {
97
+ throw new TaskTimedOutError(taskDetails);
98
+ }
99
+ } while (['THROTTLED', 'PENDING', 'RUNNING'].includes(taskDetails.status));
100
+ throw new TaskTimedOutError(taskDetails);
101
+ },
102
+ writable: false,
103
+ enumerable: false,
104
+ configurable: false,
105
+ }) as Core.APIPromise<T> & {
106
+ waitForTaskOutput: () => Promise<TaskRetrieveResponse>;
107
+ };
108
+ };
109
+ }
package/src/resource.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { RunwayML } from './index';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: RunwayML;
7
7
 
8
8
  constructor(client: RunwayML) {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
+ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/polling';
5
6
 
6
7
  export class ImageToVideo extends APIResource {
7
8
  /**
@@ -10,8 +11,10 @@ export class ImageToVideo extends APIResource {
10
11
  create(
11
12
  body: ImageToVideoCreateParams,
12
13
  options?: Core.RequestOptions,
13
- ): Core.APIPromise<ImageToVideoCreateResponse> {
14
- return this._client.post('/v1/image_to_video', { body, ...options });
14
+ ): APIPromiseWithAwaitableTask<ImageToVideoCreateResponse> {
15
+ return wrapAsWaitableResource<ImageToVideoCreateResponse>(this._client)(
16
+ this._client.post('/v1/image_to_video', { body, ...options }),
17
+ );
15
18
  }
16
19
  }
17
20
 
@@ -27,7 +30,7 @@ export interface ImageToVideoCreateParams {
27
30
  /**
28
31
  * The model variant to use.
29
32
  */
30
- model: 'gen4_turbo' | 'gen3a_turbo';
33
+ model: 'gen3a_turbo' | 'gen4_turbo';
31
34
 
32
35
  /**
33
36
  * A HTTPS URL or data URI containing an encoded image to be used as the first
@@ -55,6 +58,11 @@ export interface ImageToVideoCreateParams {
55
58
  */
56
59
  ratio: '1280:720' | '720:1280' | '1104:832' | '832:1104' | '960:960' | '1584:672' | '1280:768' | '768:1280';
57
60
 
61
+ /**
62
+ * Settings that affect the behavior of the content moderation system.
63
+ */
64
+ contentModeration?: ImageToVideoCreateParams.ContentModeration;
65
+
58
66
  /**
59
67
  * The number of seconds of duration for the output video.
60
68
  */
@@ -91,6 +99,17 @@ export namespace ImageToVideoCreateParams {
91
99
  */
92
100
  uri: string;
93
101
  }
102
+
103
+ /**
104
+ * Settings that affect the behavior of the content moderation system.
105
+ */
106
+ export interface ContentModeration {
107
+ /**
108
+ * When set to `low`, the content moderation system will be less strict about
109
+ * preventing generations that include recognizable public figures.
110
+ */
111
+ publicFigureThreshold?: 'auto' | 'low';
112
+ }
94
113
  }
95
114
 
96
115
  export declare namespace ImageToVideo {
@@ -8,3 +8,8 @@ export {
8
8
  export { Organization, type OrganizationRetrieveResponse } from './organization';
9
9
  export { Tasks, type TaskRetrieveResponse } from './tasks';
10
10
  export { TextToImage, type TextToImageCreateResponse, type TextToImageCreateParams } from './text-to-image';
11
+ export {
12
+ VideoUpscale,
13
+ type VideoUpscaleCreateResponse,
14
+ type VideoUpscaleCreateParams,
15
+ } from './video-upscale';
@@ -65,6 +65,11 @@ export namespace OrganizationRetrieveResponse {
65
65
  * Limits associated with the gen4_turbo model.
66
66
  */
67
67
  gen4_turbo?: Models.Gen4Turbo;
68
+
69
+ /**
70
+ * Limits associated with the upscale_v1 model.
71
+ */
72
+ upscale_v1?: Models.UpscaleV1;
68
73
  }
69
74
 
70
75
  export namespace Models {
@@ -112,6 +117,21 @@ export namespace OrganizationRetrieveResponse {
112
117
  */
113
118
  maxDailyGenerations: number;
114
119
  }
120
+
121
+ /**
122
+ * Limits associated with the upscale_v1 model.
123
+ */
124
+ export interface UpscaleV1 {
125
+ /**
126
+ * The maximum number of generations that can be run concurrently for this model.
127
+ */
128
+ maxConcurrentGenerations: number;
129
+
130
+ /**
131
+ * The maximum number of generations that can be created each day for this model.
132
+ */
133
+ maxDailyGenerations: number;
134
+ }
115
135
  }
116
136
  }
117
137
 
@@ -144,6 +164,11 @@ export namespace OrganizationRetrieveResponse {
144
164
  * Usage data for the gen4_turbo model.
145
165
  */
146
166
  gen4_turbo?: Models.Gen4Turbo;
167
+
168
+ /**
169
+ * Usage data for the upscale_v1 model.
170
+ */
171
+ upscale_v1?: Models.UpscaleV1;
147
172
  }
148
173
 
149
174
  export namespace Models {
@@ -176,6 +201,16 @@ export namespace OrganizationRetrieveResponse {
176
201
  */
177
202
  dailyGenerations: number;
178
203
  }
204
+
205
+ /**
206
+ * Usage data for the upscale_v1 model.
207
+ */
208
+ export interface UpscaleV1 {
209
+ /**
210
+ * The number of generations that have been run for this model in the past day.
211
+ */
212
+ dailyGenerations: number;
213
+ }
179
214
  }
180
215
  }
181
216
  }
@@ -2,14 +2,18 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
+ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/polling';
5
6
 
6
7
  export class Tasks extends APIResource {
7
8
  /**
8
9
  * Return details about a task. Consumers of this API should not expect updates
9
10
  * more frequent than once every five seconds for a given task.
10
11
  */
11
- retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<TaskRetrieveResponse> {
12
- return this._client.get(`/v1/tasks/${id}`, options);
12
+ retrieve(id: string, options?: Core.RequestOptions): APIPromiseWithAwaitableTask<TaskRetrieveResponse> {
13
+ return wrapAsWaitableResource<TaskRetrieveResponse>(this._client)(
14
+ this._client.get(`/v1/tasks/${id}`, options),
15
+ true,
16
+ );
13
17
  }
14
18
 
15
19
  /**
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { APIResource } from '../resource';
4
4
  import * as Core from '../core';
5
+ import { APIPromiseWithAwaitableTask, wrapAsWaitableResource } from '../lib/polling';
5
6
 
6
7
  export class TextToImage extends APIResource {
7
8
  /**
@@ -10,8 +11,10 @@ export class TextToImage extends APIResource {
10
11
  create(
11
12
  body: TextToImageCreateParams,
12
13
  options?: Core.RequestOptions,
13
- ): Core.APIPromise<TextToImageCreateResponse> {
14
- return this._client.post('/v1/text_to_image', { body, ...options });
14
+ ): APIPromiseWithAwaitableTask<TextToImageCreateResponse> {
15
+ return wrapAsWaitableResource<TextToImageCreateResponse>(this._client)(
16
+ this._client.post('/v1/text_to_image', { body, ...options }),
17
+ );
15
18
  }
16
19
  }
17
20