@runwayml/sdk 0.1.0-alpha.3
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 +61 -0
- package/LICENSE +201 -0
- package/README.md +329 -0
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +239 -0
- package/core.d.ts.map +1 -0
- package/core.js +887 -0
- package/core.js.map +1 -0
- package/core.mjs +856 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +118 -0
- package/index.d.ts +118 -0
- package/index.d.ts.map +1 -0
- package/index.js +118 -0
- package/index.js.map +1 -0
- package/index.mjs +90 -0
- package/index.mjs.map +1 -0
- package/package.json +103 -0
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/image-to-video.d.ts +43 -0
- package/resources/image-to-video.d.ts.map +1 -0
- package/resources/image-to-video.js +17 -0
- package/resources/image-to-video.js.map +1 -0
- package/resources/image-to-video.mjs +13 -0
- package/resources/image-to-video.mjs.map +1 -0
- package/resources/index.d.ts +3 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +9 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -0
- package/resources/tasks.d.ts +65 -0
- package/resources/tasks.d.ts.map +1 -0
- package/resources/tasks.js +32 -0
- package/resources/tasks.js.map +1 -0
- package/resources/tasks.mjs +28 -0
- package/resources/tasks.mjs.map +1 -0
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1170 -0
- package/src/error.ts +146 -0
- package/src/index.ts +205 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/image-to-video.ts +57 -0
- package/src/resources/index.ts +4 -0
- package/src/resources/tasks.ts +83 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +255 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +171 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +158 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
package/src/error.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
|
+
|
|
5
|
+
export class RunwayMLError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError extends RunwayMLError {
|
|
8
|
+
readonly status: number | undefined;
|
|
9
|
+
readonly headers: Headers | undefined;
|
|
10
|
+
readonly error: Object | undefined;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
status: number | undefined,
|
|
14
|
+
error: Object | undefined,
|
|
15
|
+
message: string | undefined,
|
|
16
|
+
headers: Headers | undefined,
|
|
17
|
+
) {
|
|
18
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.headers = headers;
|
|
21
|
+
this.error = error;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
25
|
+
const msg =
|
|
26
|
+
error?.message ?
|
|
27
|
+
typeof error.message === 'string' ?
|
|
28
|
+
error.message
|
|
29
|
+
: JSON.stringify(error.message)
|
|
30
|
+
: error ? JSON.stringify(error)
|
|
31
|
+
: message;
|
|
32
|
+
|
|
33
|
+
if (status && msg) {
|
|
34
|
+
return `${status} ${msg}`;
|
|
35
|
+
}
|
|
36
|
+
if (status) {
|
|
37
|
+
return `${status} status code (no body)`;
|
|
38
|
+
}
|
|
39
|
+
if (msg) {
|
|
40
|
+
return msg;
|
|
41
|
+
}
|
|
42
|
+
return '(no status code or body)';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static generate(
|
|
46
|
+
status: number | undefined,
|
|
47
|
+
errorResponse: Object | undefined,
|
|
48
|
+
message: string | undefined,
|
|
49
|
+
headers: Headers | undefined,
|
|
50
|
+
) {
|
|
51
|
+
if (!status) {
|
|
52
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const error = errorResponse as Record<string, any>;
|
|
56
|
+
|
|
57
|
+
if (status === 400) {
|
|
58
|
+
return new BadRequestError(status, error, message, headers);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (status === 401) {
|
|
62
|
+
return new AuthenticationError(status, error, message, headers);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (status === 403) {
|
|
66
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (status === 404) {
|
|
70
|
+
return new NotFoundError(status, error, message, headers);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (status === 409) {
|
|
74
|
+
return new ConflictError(status, error, message, headers);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (status === 422) {
|
|
78
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (status === 429) {
|
|
82
|
+
return new RateLimitError(status, error, message, headers);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (status >= 500) {
|
|
86
|
+
return new InternalServerError(status, error, message, headers);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return new APIError(status, error, message, headers);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class APIUserAbortError extends APIError {
|
|
94
|
+
override readonly status: undefined = undefined;
|
|
95
|
+
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError {
|
|
102
|
+
override readonly status: undefined = undefined;
|
|
103
|
+
|
|
104
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
105
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
106
|
+
// in some environments the 'cause' property is already declared
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
if (cause) this.cause = cause;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
113
|
+
constructor({ message }: { message?: string } = {}) {
|
|
114
|
+
super({ message: message ?? 'Request timed out.' });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class BadRequestError extends APIError {
|
|
119
|
+
override readonly status: 400 = 400;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class AuthenticationError extends APIError {
|
|
123
|
+
override readonly status: 401 = 401;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class PermissionDeniedError extends APIError {
|
|
127
|
+
override readonly status: 403 = 403;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class NotFoundError extends APIError {
|
|
131
|
+
override readonly status: 404 = 404;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class ConflictError extends APIError {
|
|
135
|
+
override readonly status: 409 = 409;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class UnprocessableEntityError extends APIError {
|
|
139
|
+
override readonly status: 422 = 422;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class RateLimitError extends APIError {
|
|
143
|
+
override readonly status: 429 = 429;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class InternalServerError extends APIError {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import * as Errors from './error';
|
|
4
|
+
import * as Uploads from './uploads';
|
|
5
|
+
import { type Agent } from './_shims/index';
|
|
6
|
+
import * as Core from './core';
|
|
7
|
+
import * as API from './resources/index';
|
|
8
|
+
|
|
9
|
+
export interface ClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Defaults to process.env['RUNWAYML_API_SECRET'].
|
|
12
|
+
*/
|
|
13
|
+
apiKey?: string | undefined;
|
|
14
|
+
|
|
15
|
+
runwayVersion?: string | undefined;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
19
|
+
*
|
|
20
|
+
* Defaults to process.env['RUNWAYML_BASE_URL'].
|
|
21
|
+
*/
|
|
22
|
+
baseURL?: string | null | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
26
|
+
* from the server before timing out a single request.
|
|
27
|
+
*
|
|
28
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
29
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
30
|
+
*/
|
|
31
|
+
timeout?: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
35
|
+
*
|
|
36
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
37
|
+
* otherwise no agent is used.
|
|
38
|
+
*/
|
|
39
|
+
httpAgent?: Agent;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Specify a custom `fetch` function implementation.
|
|
43
|
+
*
|
|
44
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
45
|
+
* defined globally.
|
|
46
|
+
*/
|
|
47
|
+
fetch?: Core.Fetch | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
51
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
52
|
+
*
|
|
53
|
+
* @default 2
|
|
54
|
+
*/
|
|
55
|
+
maxRetries?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Default headers to include with every request to the API.
|
|
59
|
+
*
|
|
60
|
+
* These can be removed in individual requests by explicitly setting the
|
|
61
|
+
* header to `undefined` or `null` in request options.
|
|
62
|
+
*/
|
|
63
|
+
defaultHeaders?: Core.Headers;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Default query parameters to include with every request to the API.
|
|
67
|
+
*
|
|
68
|
+
* These can be removed in individual requests by explicitly setting the
|
|
69
|
+
* param to `undefined` in request options.
|
|
70
|
+
*/
|
|
71
|
+
defaultQuery?: Core.DefaultQuery;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* API Client for interfacing with the RunwayML API.
|
|
76
|
+
*/
|
|
77
|
+
export class RunwayML extends Core.APIClient {
|
|
78
|
+
apiKey: string;
|
|
79
|
+
runwayVersion: string;
|
|
80
|
+
|
|
81
|
+
private _options: ClientOptions;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* API Client for interfacing with the RunwayML API.
|
|
85
|
+
*
|
|
86
|
+
* @param {string | undefined} [opts.apiKey=process.env['RUNWAYML_API_SECRET'] ?? undefined]
|
|
87
|
+
* @param {string | undefined} [opts.runwayVersion=2024-09-13]
|
|
88
|
+
* @param {string} [opts.baseURL=process.env['RUNWAYML_BASE_URL'] ?? https://api.dev.runwayml.com] - Override the default base URL for the API.
|
|
89
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
90
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
91
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
92
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
93
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
94
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
95
|
+
*/
|
|
96
|
+
constructor({
|
|
97
|
+
baseURL = Core.readEnv('RUNWAYML_BASE_URL'),
|
|
98
|
+
apiKey = Core.readEnv('RUNWAYML_API_SECRET'),
|
|
99
|
+
runwayVersion = '2024-09-13',
|
|
100
|
+
...opts
|
|
101
|
+
}: ClientOptions = {}) {
|
|
102
|
+
if (apiKey === undefined) {
|
|
103
|
+
throw new Errors.RunwayMLError(
|
|
104
|
+
"The RUNWAYML_API_SECRET environment variable is missing or empty; either provide it, or instantiate the RunwayML client with an apiKey option, like new RunwayML({ apiKey: 'My API Key' }).",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const options: ClientOptions = {
|
|
109
|
+
apiKey,
|
|
110
|
+
runwayVersion,
|
|
111
|
+
...opts,
|
|
112
|
+
baseURL: baseURL || `https://api.dev.runwayml.com`,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (Core.isRunningInBrowser()) {
|
|
116
|
+
throw new Errors.RunwayMLError(
|
|
117
|
+
"It looks like you're running in a browser-like environment, which is disabled to protect your secret API credentials from attackers. If you have a strong business need for client-side use of this API, please open a GitHub issue with your use-case and security mitigations.",
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
super({
|
|
122
|
+
baseURL: options.baseURL!,
|
|
123
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
124
|
+
httpAgent: options.httpAgent,
|
|
125
|
+
maxRetries: options.maxRetries,
|
|
126
|
+
fetch: options.fetch,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
this._options = options;
|
|
130
|
+
|
|
131
|
+
this.apiKey = apiKey;
|
|
132
|
+
this.runwayVersion = runwayVersion;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
tasks: API.Tasks = new API.Tasks(this);
|
|
136
|
+
imageToVideo: API.ImageToVideo = new API.ImageToVideo(this);
|
|
137
|
+
|
|
138
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
139
|
+
return this._options.defaultQuery;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
143
|
+
return {
|
|
144
|
+
...super.defaultHeaders(opts),
|
|
145
|
+
'X-Runway-Version': this.runwayVersion,
|
|
146
|
+
...this._options.defaultHeaders,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
151
|
+
return { Authorization: `Bearer ${this.apiKey}` };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static RunwayML = this;
|
|
155
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
156
|
+
|
|
157
|
+
static RunwayMLError = Errors.RunwayMLError;
|
|
158
|
+
static APIError = Errors.APIError;
|
|
159
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
160
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
161
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
162
|
+
static NotFoundError = Errors.NotFoundError;
|
|
163
|
+
static ConflictError = Errors.ConflictError;
|
|
164
|
+
static RateLimitError = Errors.RateLimitError;
|
|
165
|
+
static BadRequestError = Errors.BadRequestError;
|
|
166
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
167
|
+
static InternalServerError = Errors.InternalServerError;
|
|
168
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
169
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
170
|
+
|
|
171
|
+
static toFile = Uploads.toFile;
|
|
172
|
+
static fileFromPath = Uploads.fileFromPath;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const {
|
|
176
|
+
RunwayMLError,
|
|
177
|
+
APIError,
|
|
178
|
+
APIConnectionError,
|
|
179
|
+
APIConnectionTimeoutError,
|
|
180
|
+
APIUserAbortError,
|
|
181
|
+
NotFoundError,
|
|
182
|
+
ConflictError,
|
|
183
|
+
RateLimitError,
|
|
184
|
+
BadRequestError,
|
|
185
|
+
AuthenticationError,
|
|
186
|
+
InternalServerError,
|
|
187
|
+
PermissionDeniedError,
|
|
188
|
+
UnprocessableEntityError,
|
|
189
|
+
} = Errors;
|
|
190
|
+
|
|
191
|
+
export import toFile = Uploads.toFile;
|
|
192
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
193
|
+
|
|
194
|
+
export namespace RunwayML {
|
|
195
|
+
export import RequestOptions = Core.RequestOptions;
|
|
196
|
+
|
|
197
|
+
export import Tasks = API.Tasks;
|
|
198
|
+
export import TaskRetrieveResponse = API.TaskRetrieveResponse;
|
|
199
|
+
|
|
200
|
+
export import ImageToVideo = API.ImageToVideo;
|
|
201
|
+
export import ImageToVideoCreateResponse = API.ImageToVideoCreateResponse;
|
|
202
|
+
export import ImageToVideoCreateParams = API.ImageToVideoCreateParams;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default RunwayML;
|
package/src/lib/.keep
ADDED
package/src/resource.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { RunwayML } from './index';
|
|
4
|
+
|
|
5
|
+
export class APIResource {
|
|
6
|
+
protected _client: RunwayML;
|
|
7
|
+
|
|
8
|
+
constructor(client: RunwayML) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as ImageToVideoAPI from './image-to-video';
|
|
6
|
+
|
|
7
|
+
export class ImageToVideo extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* This endpoint will start a new task to generate a video from an image prompt.
|
|
10
|
+
*/
|
|
11
|
+
create(
|
|
12
|
+
body: ImageToVideoCreateParams,
|
|
13
|
+
options?: Core.RequestOptions,
|
|
14
|
+
): Core.APIPromise<ImageToVideoCreateResponse> {
|
|
15
|
+
return this._client.post('/v1/image_to_video', { body, ...options });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ImageToVideoCreateResponse {
|
|
20
|
+
/**
|
|
21
|
+
* The ID of the newly created task.
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ImageToVideoCreateParams {
|
|
27
|
+
/**
|
|
28
|
+
* The model variant to use.
|
|
29
|
+
*/
|
|
30
|
+
model: 'gen3a_turbo';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A HTTPS URL pointing to an image. Images must be JPEG, PNG, or WebP and are
|
|
34
|
+
* limited to 16MB. Responses must include a valid `Content-Length` header.
|
|
35
|
+
*/
|
|
36
|
+
promptImage: string;
|
|
37
|
+
|
|
38
|
+
promptText?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* If unspecified, a random number is chosen. Varying the seed integer is a way to
|
|
42
|
+
* get different results for the same other request parameters. Using the same seed
|
|
43
|
+
* integer for an identical request will produce similar results.
|
|
44
|
+
*/
|
|
45
|
+
seed?: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A boolean indicating whether or not the output video will contain a Runway
|
|
49
|
+
* watermark.
|
|
50
|
+
*/
|
|
51
|
+
watermark?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export namespace ImageToVideo {
|
|
55
|
+
export import ImageToVideoCreateResponse = ImageToVideoAPI.ImageToVideoCreateResponse;
|
|
56
|
+
export import ImageToVideoCreateParams = ImageToVideoAPI.ImageToVideoCreateParams;
|
|
57
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as TasksAPI from './tasks';
|
|
6
|
+
|
|
7
|
+
export class Tasks extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Return details about a task. Consumers of this API should not expect updates
|
|
10
|
+
* more frequent than once every five seconds for a given task.
|
|
11
|
+
*/
|
|
12
|
+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<TaskRetrieveResponse> {
|
|
13
|
+
return this._client.get(`/v1/tasks/${id}`, options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tasks that are running, pending, or throttled can be canceled by invoking this
|
|
18
|
+
* method. Invoking this method for other tasks will delete them.
|
|
19
|
+
*
|
|
20
|
+
* The output data associated with a deleted task will be deleted from persistent
|
|
21
|
+
* storage in accordance with our data retention policy. Aborted and deleted tasks
|
|
22
|
+
* will not be able to be fetched again in the future.
|
|
23
|
+
*/
|
|
24
|
+
delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
25
|
+
return this._client.delete(`/v1/tasks/${id}`, {
|
|
26
|
+
...options,
|
|
27
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TaskRetrieveResponse {
|
|
33
|
+
id: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The timestamp that the task was submitted at.
|
|
37
|
+
*/
|
|
38
|
+
createdAt: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* - `PENDING` tasks have been enqueued and are waiting to run.
|
|
42
|
+
* - `THROTTLED` tasks are waiting to be enqueued until other jobs have finished
|
|
43
|
+
* running.
|
|
44
|
+
* - `RUNNING` tasks are currently being processed.
|
|
45
|
+
* - `SUCCEEDED` tasks have completed successfully.
|
|
46
|
+
* - `FAILED` tasks have failed.
|
|
47
|
+
* - `CANCELLED` tasks have been aborted.
|
|
48
|
+
*/
|
|
49
|
+
status: 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'PENDING' | 'CANCELLED' | 'THROTTLED';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If the status is `FAILED`, this will contain a human-friendly reason for the
|
|
53
|
+
* failure.
|
|
54
|
+
*/
|
|
55
|
+
failure?: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If the task has a status of `FAILED`, this contains a machine-readable error
|
|
59
|
+
* code. This is a dot-separated string, with the leftmost segment being the most
|
|
60
|
+
* generic and the rightmost segment being the most specific. For example,
|
|
61
|
+
* `SAFETY.INPUT.TEXT` would indicate that the task failed due to a content
|
|
62
|
+
* moderation error on the input text.
|
|
63
|
+
*/
|
|
64
|
+
failureCode?: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* If the status is `SUCCEEDED`, this will contain an array of strings. Each string
|
|
68
|
+
* will be a URL that returns an output from the task. URLs expire within 24-48
|
|
69
|
+
* hours; fetch the task again to get fresh URLs. It is expected that you download
|
|
70
|
+
* the assets at these URLs and store them in your own storage system.
|
|
71
|
+
*/
|
|
72
|
+
output?: Array<string>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* If the task has a status of `RUNNING`, this will contain a floating point number
|
|
76
|
+
* between 0 and 1 representing the progress of the generation.
|
|
77
|
+
*/
|
|
78
|
+
progress?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export namespace Tasks {
|
|
82
|
+
export import TaskRetrieveResponse = TasksAPI.TaskRetrieveResponse;
|
|
83
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as types from '../_shims/node-types';
|
|
3
|
+
import { setShims } from '../_shims/registry';
|
|
4
|
+
import { getRuntime } from '../_shims/node-runtime';
|
|
5
|
+
setShims(getRuntime());
|
|
6
|
+
|
|
7
|
+
declare module '../_shims/manual-types' {
|
|
8
|
+
export namespace manual {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
export type Agent = types.Agent;
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
export import fetch = types.fetch;
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
export type Request = types.Request;
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
export type RequestInfo = types.RequestInfo;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
export type RequestInit = types.RequestInit;
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
export type Response = types.Response;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
export type ResponseInit = types.ResponseInit;
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
export type ResponseType = types.ResponseType;
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
export type BodyInit = types.BodyInit;
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
export type Headers = types.Headers;
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
export type HeadersInit = types.HeadersInit;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
export type BlobPropertyBag = types.BlobPropertyBag;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
export type FilePropertyBag = types.FilePropertyBag;
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
export type FileFromPathOptions = types.FileFromPathOptions;
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
export import FormData = types.FormData;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
export import File = types.File;
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
export import Blob = types.Blob;
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
export type Readable = types.Readable;
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
export type FsReadStream = types.FsReadStream;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
export import ReadableStream = types.ReadableStream;
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/shims/web.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import * as types from '../_shims/web-types';
|
|
3
|
+
import { setShims } from '../_shims/registry';
|
|
4
|
+
import { getRuntime } from '../_shims/web-runtime';
|
|
5
|
+
setShims(getRuntime({ manuallyImported: true }));
|
|
6
|
+
|
|
7
|
+
declare module '../_shims/manual-types' {
|
|
8
|
+
export namespace manual {
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
export type Agent = types.Agent;
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
export import fetch = types.fetch;
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
export type Request = types.Request;
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
export type RequestInfo = types.RequestInfo;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
export type RequestInit = types.RequestInit;
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
export type Response = types.Response;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
export type ResponseInit = types.ResponseInit;
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
export type ResponseType = types.ResponseType;
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
export type BodyInit = types.BodyInit;
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
export type Headers = types.Headers;
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
export type HeadersInit = types.HeadersInit;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
export type BlobPropertyBag = types.BlobPropertyBag;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
export type FilePropertyBag = types.FilePropertyBag;
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
export type FileFromPathOptions = types.FileFromPathOptions;
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
export import FormData = types.FormData;
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
export import File = types.File;
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
export import Blob = types.Blob;
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
export type Readable = types.Readable;
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
export type FsReadStream = types.FsReadStream;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
export import ReadableStream = types.ReadableStream;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
// this config is included in the published src directory to prevent TS errors
|
|
3
|
+
// from appearing when users go to source, and VSCode opens the source .ts file
|
|
4
|
+
// via declaration maps
|
|
5
|
+
"include": ["index.ts"],
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"target": "es2015",
|
|
8
|
+
"lib": ["DOM"],
|
|
9
|
+
"moduleResolution": "node"
|
|
10
|
+
}
|
|
11
|
+
}
|