### Install @runwayml/sdk Source: https://github.com/runwayml/sdk-node/blob/main/README.md Install the SDK using npm. This is the first step to using the library. ```sh npm install @runwayml/sdk ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Run these commands to set up the repository and build the project. This installs all necessary dependencies and compiles the output files. ```sh $ yarn $ yarn build ``` -------------------------------- ### Install SDK from Git Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Use this command to install the SDK directly from its GitHub repository using SSH. ```sh $ npm install git+ssh://git@github.com:runwayml/sdk-node.git ``` -------------------------------- ### Add and Run Examples Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Add new examples to the `examples/` directory. Make the script executable and then run it using `yarn tsn`. ```ts // add an example to examples/.ts #!/usr/bin/env -S npm run tsn -T … ``` ```sh $ chmod +x examples/.ts # run the example against your api $ yarn tsn -T examples/.ts ``` -------------------------------- ### Start Mock Server Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Run this script to set up a mock server for testing purposes. This is required for most tests. ```sh $ ./scripts/mock ``` -------------------------------- ### Bun package.json Dependency Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Install the @types/bun package for Bun environments. A version greater than or equal to 1.2.0 is required. ```json { "devDependencies": { "@types/bun": ">= 1.2.0" } } ``` -------------------------------- ### Paginate List Results Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md The interface for manual pagination has been simplified. Use 'nextPageRequestOptions()' to get the options for the next page. ```typescript // Automatically fetches more pages as needed. for await (const avatarListResponse of client.avatars.list({ limit: 1 })) { console.log(avatarListResponse); } // Before // page.nextPageParams(); // page.nextPageInfo(); // Required manually handling { url } | { params } type // After page.nextPageRequestOptions(); ``` -------------------------------- ### client.realtimeSessions.retrieve Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves an existing Realtime Session by its ID. Use this to get details about a specific session. ```APIDOC ## GET /v1/realtime_sessions/{id} ### Description Retrieves an existing Realtime Session by its ID. ### Method GET ### Endpoint /v1/realtime_sessions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Realtime Session to retrieve. ### Response #### Success Response (200) - **RealtimeSessionRetrieveResponse** - The response object containing details of the requested session. ``` -------------------------------- ### Avatars Get Usage Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves usage statistics for avatars. ```APIDOC ## GET /v1/avatar_usage ### Description Retrieves usage statistics for avatars. ### Method GET ### Endpoint /v1/avatar_usage ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (AvatarGetUsageResponse) - The response object containing avatar usage statistics. ``` -------------------------------- ### Node.js package.json Dependency Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Install the appropriate @types/node package for Node.js environments to resolve type errors. Version 20 or higher is recommended. ```json { "devDependencies": { "@types/node": ">= 20" } } ``` -------------------------------- ### Cloudflare Workers package.json Dependency Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Install the @cloudflare/workers-types package for Cloudflare Workers environments. A version greater than or equal to 0.20221111.0 is required. ```json { "devDependencies": { "@cloudflare/workers-types": ">= 0.20221111.0" } } ``` -------------------------------- ### Run Tests Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Execute the test suite for the SDK. Ensure the mock server is running. ```sh $ yarn run test ``` -------------------------------- ### Create an Image-to-Video Transformation Source: https://github.com/runwayml/sdk-node/blob/main/README.md Use the client to create an image-to-video transformation. Requires an API key and specifies model, prompt image, ratio, and text prompt. ```js import RunwayML from '@runwayml/sdk'; const client = new RunwayML({ apiKey: process.env['RUNWAYML_API_SECRET'], // This is the default and can be omitted }); const imageToVideo = await client.imageToVideo.create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }); console.log(imageToVideo.id); ``` -------------------------------- ### client.textToVideo.create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a text-to-video generation job. ```APIDOC ## POST /v1/text_to_video ### Description Creates a text-to-video generation job. ### Method POST ### Endpoint /v1/text_to_video ### Parameters #### Request Body - **params** (object) - Required - Parameters for the text-to-video job. The exact fields are not specified in the source. ### Response #### Success Response (200) - **TextToVideoCreateResponse** (object) - The response containing details of the created job. ``` -------------------------------- ### Configure Deno Proxy Source: https://github.com/runwayml/sdk-node/blob/main/README.md For Deno, configure proxy settings by creating a `Deno.HttpClient` with proxy details and passing it via `fetchOptions.client`. ```typescript import RunwayML from 'npm:@runwayml/sdk'; const httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } }); const client = new RunwayML({ fetchOptions: { client: httpClient, }, }); ``` -------------------------------- ### client.videoToVideo.create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a video-to-video generation job. ```APIDOC ## POST /v1/video_to_video ### Description Creates a video-to-video generation job. ### Method POST ### Endpoint /v1/video_to_video ### Parameters #### Request Body - **params** (object) - Required - Parameters for the video-to-video job. The exact fields are not specified in the source. ### Response #### Success Response (200) - **VideoToVideoCreateResponse** (object) - The response containing details of the created job. ``` -------------------------------- ### client.imageToVideo.create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates an image-to-video generation job. ```APIDOC ## POST /v1/image_to_video ### Description Creates an image-to-video generation job. ### Method POST ### Endpoint /v1/image_to_video ### Parameters #### Request Body - **params** (object) - Required - Parameters for the image-to-video job. The exact fields are not specified in the source. ### Response #### Success Response (200) - **ImageToVideoCreateResponse** (object) - The response containing details of the created job. ``` -------------------------------- ### Configure Bun Proxy Source: https://github.com/runwayml/sdk-node/blob/main/README.md In Bun environments, proxy settings can be configured directly using the `proxy` option within `fetchOptions`. ```typescript import RunwayML from '@runwayml/sdk'; const client = new RunwayML({ fetchOptions: { proxy: 'http://localhost:8888', }, }); ``` -------------------------------- ### Link Local SDK Repository with pnpm Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Clone the repository, link it globally, and then link it to your project package using pnpm. ```sh # With pnpm $ pnpm link --global $ cd ../my-package $ pnpm link --global @runwayml/sdk ``` -------------------------------- ### Configure Client with Fetch Options Source: https://github.com/runwayml/sdk-node/blob/main/README.md Provide custom `fetchOptions` during client instantiation to set default fetch configurations. These can be overridden by request-specific options. ```typescript import RunwayML from '@runwayml/sdk'; const client = new RunwayML({ fetchOptions: { // `RequestInit` options }, }); ``` -------------------------------- ### Configure Proxy with fetchOptions and undici.ProxyAgent Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Replace the deprecated `httpAgent` client option with `fetchOptions` and an `undici.ProxyAgent` for configuring proxies, as `httpAgent` is not compatible with builtin fetch implementations. ```typescript import RunwayML from '@runwayml/sdk'; import * as undici from 'undici'; const proxyAgent = new undici.ProxyAgent(process.env.PROXY_URL); const client = new RunwayML({ fetchOptions: { dispatcher: proxyAgent, }, }); ``` -------------------------------- ### Handle Request Options for Methods Without Required Body/Query/Headers Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Methods that previously accepted optional parameters without explicit `null`, `undefined`, or `{}` now require them to customize request options like headers. ```diff client.example.list(); client.example.list({}, { headers: { ... } }); client.example.list(null, { headers: { ... } }); client.example.list(undefined, { headers: { ... } }); - client.example.list({ headers: { ... } }); + client.example.list({}, { headers: { ... } }); ``` -------------------------------- ### Polyfill Global Fetch Source: https://github.com/runwayml/sdk-node/blob/main/README.md If you need to use a custom fetch implementation, you can polyfill the global `fetch` function before initializing the client. ```typescript import fetch from 'my-fetch'; globalThis.fetch = fetch; ``` -------------------------------- ### client.recipes.productCampaignImage Source: https://github.com/runwayml/sdk-node/blob/main/api.md Generates a product campaign image using the recipes API. Use this for broader marketing campaigns. ```APIDOC ## POST /v1/recipes/product_campaign_image ### Description Generates a product campaign image using the recipes API. ### Method POST ### Endpoint /v1/recipes/product_campaign_image ### Parameters #### Request Body - **params** (object) - Required - Parameters for generating the product campaign image. ### Response #### Success Response (200) - **RecipeProductCampaignImageResponse** - The response object containing the generated product campaign image. ``` -------------------------------- ### TextToSpeech Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a text-to-speech audio output. This method corresponds to the POST /v1/text_to_speech endpoint. ```APIDOC ## POST /v1/text_to_speech ### Description Creates a text-to-speech audio output. ### Method POST ### Endpoint /v1/text_to_speech ### Parameters #### Request Body - **params** (object) - Required - Parameters for text-to-speech conversion. ### Response #### Success Response (200) - **TextToSpeechCreateResponse** (object) - The response object for text-to-speech creation. ``` -------------------------------- ### Import Resource Classes Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Resource classes are no longer directly exportable from the root. Import them via the main client or directly from their respective files. ```javascript // Before const { Tasks } = require('@runwayml/sdk'); // After const { RunwayML } = require('@runwayml/sdk'); RunwayML.Tasks; // or import directly from @runwayml/sdk/resources/tasks ``` -------------------------------- ### client.recipes.productSwap Source: https://github.com/runwayml/sdk-node/blob/main/api.md Performs a product swap using the recipes API. This method allows for replacing elements within product imagery. ```APIDOC ## POST /v1/recipes/product_swap ### Description Performs a product swap using the recipes API. ### Method POST ### Endpoint /v1/recipes/product_swap ### Parameters #### Request Body - **params** (object) - Required - Parameters for performing the product swap. ### Response #### Success Response (200) - **RecipeProductSwapResponse** - The response object containing the result of the product swap. ``` -------------------------------- ### Create Document Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new document with the provided parameters. ```APIDOC ## POST /v1/documents ### Description Creates a new document with the provided parameters. ### Method POST ### Endpoint /v1/documents ### Parameters #### Request Body - **params** (object) - Required - Parameters for creating the document. ### Response #### Success Response (200) - **DocumentCreateResponse** - The details of the created document. ``` -------------------------------- ### client.textToImage.create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a text-to-image generation job. ```APIDOC ## POST /v1/text_to_image ### Description Creates a text-to-image generation job. ### Method POST ### Endpoint /v1/text_to_image ### Parameters #### Request Body - **params** (object) - Required - Parameters for the text-to-image job. The exact fields are not specified in the source. ### Response #### Success Response (200) - **TextToImageCreateResponse** (object) - The response containing details of the created job. ``` -------------------------------- ### client.recipes.productAd Source: https://github.com/runwayml/sdk-node/blob/main/api.md Generates a product ad image using the recipes API. Ideal for creating advertisements for products. ```APIDOC ## POST /v1/recipes/product_ad ### Description Generates a product ad image using the recipes API. ### Method POST ### Endpoint /v1/recipes/product_ad ### Parameters #### Request Body - **params** (object) - Required - Parameters for generating the product ad image. ### Response #### Success Response (200) - **RecipeProductAdResponse** - The response object containing the generated product ad image. ``` -------------------------------- ### Link Local SDK Repository with Yarn Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Clone the repository, link it globally, and then link it to your project package. This is useful for development. ```sh # Clone $ git clone https://www.github.com/runwayml/sdk-node $ cd sdk-node # With yarn $ yarn link $ cd ../my-package $ yarn link @runwayml/sdk ``` -------------------------------- ### SpeechToSpeech Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new speech-to-speech conversion. ```APIDOC ## POST /v1/speech_to_speech ### Description Creates a new speech-to-speech conversion. ### Method POST ### Endpoint /v1/speech_to_speech ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (SpeechToSpeechCreateResponse) - The response object containing details of the speech-to-speech conversion. ``` -------------------------------- ### Provide Custom Logger to Client Source: https://github.com/runwayml/sdk-node/blob/main/README.md Integrate a custom logger, such as pino, by passing it to the `logger` option during client initialization. The `logLevel` option still governs which messages are emitted to the custom logger. ```typescript import RunwayML from '@runwayml/sdk'; import pino from 'pino'; const logger = pino(); const client = new RunwayML({ logger: logger.child({ name: 'RunwayML' }), logLevel: 'debug', // Send all messages to pino, allowing it to filter }); ``` -------------------------------- ### Publish NPM Package Manually Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Manually release a package to npm by running the `bin/publish-npm` script. Ensure the `NPM_TOKEN` environment variable is set. ```sh bin/publish-npm ``` -------------------------------- ### Configure Node.js Proxy with Undici Source: https://github.com/runwayml/sdk-node/blob/main/README.md For Node.js environments, configure proxy behavior by providing a `ProxyAgent` instance within `fetchOptions.dispatcher`. ```typescript import RunwayML from '@runwayml/sdk'; import * as undici from 'undici'; const proxyAgent = new undici.ProxyAgent('http://localhost:8888'); const client = new RunwayML({ fetchOptions: { dispatcher: proxyAgent, }, }); ``` -------------------------------- ### Create Avatar Video Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new avatar video with the provided parameters. ```APIDOC ## POST /v1/avatar_videos ### Description Creates a new avatar video with the provided parameters. ### Method POST ### Endpoint /v1/avatar_videos ### Parameters #### Request Body - **params** (object) - Required - Parameters for creating the avatar video. ### Response #### Success Response (200) - **AvatarVideoCreateResponse** - The details of the created avatar video. ``` -------------------------------- ### client.realtimeSessions.create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new Realtime Session. This method is used to initiate a new session for real-time operations. ```APIDOC ## POST /v1/realtime_sessions ### Description Creates a new Realtime Session. ### Method POST ### Endpoint /v1/realtime_sessions ### Parameters #### Request Body - **params** (object) - Required - Parameters for creating the session. ### Response #### Success Response (200) - **RealtimeSessionCreateResponse** - The response object upon successful creation of the session. ``` -------------------------------- ### SoundEffect Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new sound effect. This method corresponds to the POST /v1/sound_effect endpoint. ```APIDOC ## POST /v1/sound_effect ### Description Creates a new sound effect. ### Method POST ### Endpoint /v1/sound_effect ### Parameters #### Request Body - **params** (object) - Required - Parameters for creating a sound effect. ### Response #### Success Response (200) - **SoundEffectCreateResponse** (object) - The response object for sound effect creation. ``` -------------------------------- ### client.recipes.productUgc Source: https://github.com/runwayml/sdk-node/blob/main/api.md Generates user-generated content (UGC) for a product using the recipes API. This is useful for creating authentic-looking product content. ```APIDOC ## POST /v1/recipes/product_ugc ### Description Generates user-generated content (UGC) for a product using the recipes API. ### Method POST ### Endpoint /v1/recipes/product_ugc ### Parameters #### Request Body - **params** (object) - Required - Parameters for generating the product UGC. ### Response #### Success Response (200) - **RecipeProductUgcResponse** - The response object containing the generated product UGC. ``` -------------------------------- ### Replace APIClient Import Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md The 'APIClient' base class has been removed. Use the main 'RunwayML' client class instead. ```typescript // Before import { APIClient } from '@runwayml/sdk/core'; // After import { RunwayML } from '@runwayml/sdk'; ``` -------------------------------- ### VoiceDubbing Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Performs voice dubbing. This method corresponds to the POST /v1/voice_dubbing endpoint. ```APIDOC ## POST /v1/voice_dubbing ### Description Performs voice dubbing. ### Method POST ### Endpoint /v1/voice_dubbing ### Parameters #### Request Body - **params** (object) - Required - Parameters for voice dubbing. ### Response #### Success Response (200) - **VoiceDubbingCreateResponse** (object) - The response object for voice dubbing creation. ``` -------------------------------- ### Avatars Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new avatar. ```APIDOC ## POST /v1/avatars ### Description Creates a new avatar. ### Method POST ### Endpoint /v1/avatars ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (AvatarCreateResponse) - The response object containing details of the created avatar. ``` -------------------------------- ### Use TypeScript Definitions for Request/Response Source: https://github.com/runwayml/sdk-node/blob/main/README.md Leverage TypeScript definitions for precise request parameters and response fields. Import types like `ImageToVideoCreateParams` and `ImageToVideoCreateResponse`. ```ts import RunwayML from '@runwayml/sdk'; const client = new RunwayML({ apiKey: process.env['RUNWAYML_API_SECRET'], // This is the default and can be omitted }); const params: RunwayML.ImageToVideoCreateParams = { model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }; const imageToVideo: RunwayML.ImageToVideoCreateResponse = await client.imageToVideo.create(params); ``` -------------------------------- ### ImageUpscale Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Upscales an image. ```APIDOC ## POST /v1/image_upscale ### Description Upscales an image. ### Method POST ### Endpoint /v1/image_upscale ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (ImageUpscaleCreateResponse) - The response object containing the upscaled image details. ``` -------------------------------- ### client.recipes.multiShotVideo Source: https://github.com/runwayml/sdk-node/blob/main/api.md Generates a multi-shot video using the recipes API. This method is designed for creating dynamic video content. ```APIDOC ## POST /v1/recipes/multi_shot_video ### Description Generates a multi-shot video using the recipes API. ### Method POST ### Endpoint /v1/recipes/multi_shot_video ### Parameters #### Request Body - **params** (object) - Required - Parameters for generating the multi-shot video. ### Response #### Success Response (200) - **RecipeMultiShotVideoResponse** - The response object containing the generated multi-shot video. ``` -------------------------------- ### Lint Code Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Run the lint command to check for code style issues and potential errors. ```sh $ yarn lint ``` -------------------------------- ### Migrate Response Body from Node Readable to Web ReadableStream Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md When using `asResponse()`, the `body` is now a Web `ReadableStream`. Use `Readable.fromWeb()` to convert it for piping to `process.stdout`. ```typescript // Before: const res = await client.example.retrieve('string/with/slash').asResponse(); res.body.pipe(process.stdout); // After: import { Readable } from 'node:stream'; const res = await client.example.retrieve('string/with/slash').asResponse(); Readable.fromWeb(res.body).pipe(process.stdout); ``` -------------------------------- ### Replace src Directory Imports Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Imports from the internal '@runwayml/sdk/src' directory should be replaced with imports from the root '@runwayml/sdk'. ```typescript // Before import RunwayML from '@runwayml/sdk/src'; // After import RunwayML from '@runwayml/sdk'; ``` -------------------------------- ### CharacterPerformance Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Creates a new character performance. This method corresponds to the POST /v1/character_performance endpoint. ```APIDOC ## POST /v1/character_performance ### Description Creates a new character performance. ### Method POST ### Endpoint /v1/character_performance ### Parameters #### Request Body - **params** (object) - Required - Parameters for creating a character performance. ### Response #### Success Response (200) - **CharacterPerformanceCreateResponse** (object) - The response object for character performance creation. ``` -------------------------------- ### Format and Fix Lint Issues Source: https://github.com/runwayml/sdk-node/blob/main/CONTRIBUTING.md Automatically format the code and fix any linting issues found in the repository. ```sh $ yarn fix ``` -------------------------------- ### Configure Client Log Level Source: https://github.com/runwayml/sdk-node/blob/main/README.md Set the `logLevel` option during client initialization to control the verbosity of log messages. Available levels range from 'debug' (most verbose) to 'off' (no logging). This setting overrides the `RUNWAYML_LOG` environment variable. ```typescript import RunwayML from '@runwayml/sdk'; const client = new RunwayML({ logLevel: 'debug', // Show all log messages }); ``` -------------------------------- ### Pass Custom Fetch to Client Source: https://github.com/runwayml/sdk-node/blob/main/README.md Alternatively, you can pass a custom fetch implementation directly to the RunwayML client constructor. ```typescript import RunwayML from '@runwayml/sdk'; import fetch from 'my-fetch'; const client = new RunwayML({ fetch }); ``` -------------------------------- ### client.recipes.marketingStockImage Source: https://github.com/runwayml/sdk-node/blob/main/api.md Generates a marketing stock image using the recipes API. This is useful for creating promotional visual assets. ```APIDOC ## POST /v1/recipes/marketing_stock_image ### Description Generates a marketing stock image using the recipes API. ### Method POST ### Endpoint /v1/recipes/marketing_stock_image ### Parameters #### Request Body - **params** (object) - Required - Parameters for generating the marketing stock image. ### Response #### Success Response (200) - **RecipeMarketingStockImageResponse** - The response object containing the generated marketing stock image. ``` -------------------------------- ### Manually Paginate Through API Responses Source: https://github.com/runwayml/sdk-node/blob/main/README.md Request a single page of data at a time and use convenience methods like `hasNextPage()` and `getNextPage()` for manual pagination control. This is useful when you need to process data page by page or have specific pagination requirements. ```typescript let page = await client.avatars.list({ limit: 1 }); for (const avatarListResponse of page.data) { console.log(avatarListResponse); } // Convenience methods are provided for manually paginating: while (page.hasNextPage()) { page = await page.getNextPage(); // ... } ``` -------------------------------- ### Iterate Through All Paginated Items Source: https://github.com/runwayml/sdk-node/blob/main/README.md Use `for await...of` to automatically fetch and iterate through all items across paginated API responses. This simplifies handling large datasets by abstracting away manual pagination logic. ```typescript async function fetchAllAvatarListResponses(params) { const allAvatarListResponses = []; // Automatically fetches more pages as needed. for await (const avatarListResponse of client.avatars.list({ limit: 1 })) { allAvatarListResponses.push(avatarListResponse); } return allAvatarListResponses; } ``` -------------------------------- ### Configure Default Timeout Source: https://github.com/runwayml/sdk-node/blob/main/README.md Set the default request timeout for all API calls by providing the `timeout` option during client initialization. The default is 1 minute. ```ts // Configure the default for all requests: const client = new RunwayML({ timeout: 20 * 1000, // 20 seconds (default is 1 minute) }); ``` -------------------------------- ### List Documents Source: https://github.com/runwayml/sdk-node/blob/main/api.md Lists documents with optional filtering parameters. ```APIDOC ## GET /v1/documents ### Description Lists documents with optional filtering parameters. ### Method GET ### Endpoint /v1/documents ### Parameters #### Query Parameters - **params** (object) - Optional - Parameters for filtering and pagination. ### Response #### Success Response (200) - **DocumentListResponsesCursorPage** - A cursor-paginated list of documents. ``` -------------------------------- ### Access Raw Response and Parsed Data with .withResponse() Source: https://github.com/runwayml/sdk-node/blob/main/README.md Utilize the `.withResponse()` method to retrieve both the raw `Response` object and the parsed data. This method consumes the response body and resolves once both are available, providing convenient access to both. ```typescript const { data: imageToVideo, response: raw } = await client.imageToVideo .create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }) .withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(imageToVideo.id); ``` -------------------------------- ### Organization Retrieve Usage Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves organization usage statistics. ```APIDOC ## POST /v1/organization/usage ### Description Retrieves organization usage statistics. ### Method POST ### Endpoint /v1/organization/usage ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (OrganizationRetrieveUsageResponse) - The response object containing organization usage statistics. ``` -------------------------------- ### Remove Shim Imports Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Imports for '@runwayml/sdk/shims' have been removed. Ensure your global types are correctly configured. ```typescript // Tell TypeScript and the package to use the global Web fetch instead of node-fetch. import '@runwayml/sdk/shims/web'; import RunwayML from '@runwayml/sdk'; ``` -------------------------------- ### Browser tsconfig.json Configuration Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Configure tsconfig.json for browser environments to resolve type errors. Ensure 'lib' includes 'DOM' and 'DOM.Iterable'. ```json { "target": "ES2018", "lib": ["DOM", "DOM.Iterable", "ES2018"] } ``` -------------------------------- ### Avatars List Source: https://github.com/runwayml/sdk-node/blob/main/api.md Lists all avatars with optional filtering. ```APIDOC ## GET /v1/avatars ### Description Lists all avatars with optional filtering. ### Method GET ### Endpoint /v1/avatars ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (AvatarListResponsesCursorPage) - A paginated list of avatars. ``` -------------------------------- ### Access Raw Response Data with .asResponse() Source: https://github.com/runwayml/sdk-node/blob/main/README.md Use the `.asResponse()` method to access the raw `Response` object returned by `fetch()`. This method resolves as soon as headers are received, allowing for custom parsing or streaming without consuming the response body. ```typescript const client = new RunwayML(); const response = await client.imageToVideo .create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }) .asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object ``` -------------------------------- ### client.tasks.retrieve Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves a specific task by its ID. ```APIDOC ## GET /v1/tasks/{id} ### Description Retrieves a specific task by its ID. ### Method GET ### Endpoint /v1/tasks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the task to retrieve. ### Response #### Success Response (200) - **TaskRetrieveResponse** (object) - The details of the retrieved task. ``` -------------------------------- ### Configure Default Max Retries Source: https://github.com/runwayml/sdk-node/blob/main/README.md Set the default number of retries for all requests by configuring the `maxRetries` option during client initialization. The default is 2. ```js // Configure the default for all requests: const client = new RunwayML({ maxRetries: 0, // default is 2 }); ``` -------------------------------- ### Workflows API Source: https://github.com/runwayml/sdk-node/blob/main/api.md Methods for managing workflows, including retrieval, listing, and running. ```APIDOC ## GET /v1/workflows/{id} ### Description Retrieves a specific workflow by its ID. ### Method GET ### Endpoint /v1/workflows/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the workflow to retrieve. ### Response #### Success Response (200) - **WorkflowRetrieveResponse** (object) - The response object for retrieving a workflow. ``` ```APIDOC ## GET /v1/workflows ### Description Lists all available workflows. ### Method GET ### Endpoint /v1/workflows ### Response #### Success Response (200) - **WorkflowListResponse** (object) - The response object containing a list of workflows. ``` ```APIDOC ## POST /v1/workflows/{id} ### Description Runs a specific workflow by its ID. ### Method POST ### Endpoint /v1/workflows/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the workflow to run. ### Request Body - **params** (object) - Required - Parameters for running the workflow. ### Response #### Success Response (200) - **WorkflowRunResponse** (object) - The response object indicating the result of the workflow run. ``` -------------------------------- ### Voices API Source: https://github.com/runwayml/sdk-node/blob/main/api.md Methods for managing voices, including creation, retrieval, update, listing, deletion, and preview. ```APIDOC ## POST /v1/voices ### Description Creates a new voice. ### Method POST ### Endpoint /v1/voices ### Request Body - **params** (object) - Required - Parameters for voice creation. ### Response #### Success Response (200) - **VoiceCreateResponse** (object) - The response object for voice creation. ``` ```APIDOC ## GET /v1/voices/{id} ### Description Retrieves a specific voice by its ID. ### Method GET ### Endpoint /v1/voices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the voice to retrieve. ### Response #### Success Response (200) - **VoiceRetrieveResponse** (object) - The response object for retrieving a voice. ``` ```APIDOC ## PATCH /v1/voices/{id} ### Description Updates an existing voice by its ID. ### Method PATCH ### Endpoint /v1/voices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the voice to update. ### Request Body - **params** (object) - Required - Parameters for voice update. ### Response #### Success Response (200) - **VoiceUpdateResponse** (object) - The response object for updating a voice. ``` ```APIDOC ## GET /v1/voices ### Description Lists all available voices. ### Method GET ### Endpoint /v1/voices ### Request Body - **params** (object) - Optional - Parameters for filtering or paginating the voice list. ### Response #### Success Response (200) - **VoiceListResponsesCursorPage** (object) - A cursor-paginated response object containing a list of voices. ``` ```APIDOC ## DELETE /v1/voices/{id} ### Description Deletes a voice by its ID. ### Method DELETE ### Endpoint /v1/voices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the voice to delete. ### Response #### Success Response (200) - **void** - Indicates successful deletion. ``` ```APIDOC ## POST /v1/voices/preview ### Description Generates a preview for a voice. ### Method POST ### Endpoint /v1/voices/preview ### Request Body - **params** (object) - Required - Parameters for voice preview generation. ### Response #### Success Response (200) - **VoicePreviewResponse** (object) - The response object containing the voice preview. ``` -------------------------------- ### List Avatar Conversations Source: https://github.com/runwayml/sdk-node/blob/main/api.md Lists avatar conversations with optional filtering parameters. ```APIDOC ## GET /v1/avatar_conversations ### Description Lists avatar conversations with optional filtering parameters. ### Method GET ### Endpoint /v1/avatar_conversations ### Parameters #### Query Parameters - **params** (object) - Optional - Parameters for filtering and pagination. ### Response #### Success Response (200) - **AvatarConversationListResponsesCursorPage** - A cursor-paginated list of avatar conversations. ``` -------------------------------- ### Update Core Module Imports Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Refactored core modules are now located in the 'core' directory. Update your import paths accordingly. ```typescript // Before import '@runwayml/sdk/error'; import '@runwayml/sdk/pagination'; import '@runwayml/sdk/resource'; import '@runwayml/sdk/uploads'; // After import '@runwayml/sdk/core/error'; import '@runwayml/sdk/core/pagination'; import '@runwayml/sdk/core/resource'; import '@runwayml/sdk/core/uploads'; ``` -------------------------------- ### Node.js tsconfig.json Configuration Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Configure tsconfig.json for Node.js environments. The 'target' is set to ES2018, with a recommendation for ES2020 or higher. ```json { "target": "ES2018" } ``` -------------------------------- ### Organization Retrieve Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves organization details. ```APIDOC ## GET /v1/organization ### Description Retrieves organization details. ### Method GET ### Endpoint /v1/organization ### Response #### Success Response (200) - **response** (OrganizationRetrieveResponse) - The response object containing organization details. ``` -------------------------------- ### Avatars Update Source: https://github.com/runwayml/sdk-node/blob/main/api.md Updates an existing avatar. ```APIDOC ## PATCH /v1/avatars/{id} ### Description Updates an existing avatar. ### Method PATCH ### Endpoint /v1/avatars/{id} #### Path Parameters - **id** (string) - Required - The unique identifier of the avatar. ### Request Example ```json { "params": { ... } } ``` ### Response #### Success Response (200) - **response** (AvatarUpdateResponse) - The response object containing details of the updated avatar. ``` -------------------------------- ### Make Undocumented POST Requests Source: https://github.com/runwayml/sdk-node/blob/main/README.md Use `client.post` to make requests to undocumented endpoints. This method respects client options like retries and allows specifying request body and query parameters. ```typescript await client.post('/some/path', { body: { some_prop: 'foo' }, query: { some_query_arg: 'bar' }, }); ``` -------------------------------- ### Update Page Class Type Aliases Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Page classes for individual methods are now type aliases. If importing at runtime, switch to importing the base class or import at type-level only. ```typescript // Before export class AvatarListResponsesCursorPage extends CursorPage {} // After export type AvatarListResponsesCursorPage = CursorPage; ``` -------------------------------- ### VoiceIsolation Create Source: https://github.com/runwayml/sdk-node/blob/main/api.md Performs voice isolation. This method corresponds to the POST /v1/voice_isolation endpoint. ```APIDOC ## POST /v1/voice_isolation ### Description Performs voice isolation. ### Method POST ### Endpoint /v1/voice_isolation ### Parameters #### Request Body - **params** (object) - Required - Parameters for voice isolation. ### Response #### Success Response (200) - **VoiceIsolationCreateResponse** (object) - The response object for voice isolation creation. ``` -------------------------------- ### Configure Per-Request Timeout Source: https://github.com/runwayml/sdk-node/blob/main/README.md Override the default timeout for a specific request by including the `timeout` option in the request options. This is useful for requests that may take longer or need to be faster. ```ts // Override per-request: await client.imageToVideo.create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }, { timeout: 5 * 1000, }); ``` -------------------------------- ### Retrieve Document Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves a specific document by its ID. ```APIDOC ## GET /v1/documents/{id} ### Description Retrieves a specific document by its ID. ### Method GET ### Endpoint /v1/documents/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the document. ### Response #### Success Response (200) - **DocumentRetrieveResponse** - The details of the retrieved document. ``` -------------------------------- ### Handle API Errors with Catch Block Source: https://github.com/runwayml/sdk-node/blob/main/README.md Implement error handling for API requests using a .catch block. Differentiate between `APIError` subclasses like `BadRequestError` and other error types. ```ts const imageToVideo = await client.imageToVideo .create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }) .catch(async (err) => { if (err instanceof RunwayML.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError console.log(err.headers); // {server: 'nginx', ...} } else { throw err; } }); ``` -------------------------------- ### Configure Per-Request Max Retries Source: https://github.com/runwayml/sdk-node/blob/main/README.md Override the default retry behavior for a specific request by passing the `maxRetries` option in the request options object. This allows for granular control over retries. ```js // Or, configure per-request: await client.imageToVideo.create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', ratio: '1280:720', promptText: 'The bunny is eating a carrot', }, { maxRetries: 5, }); ``` -------------------------------- ### Avatars Retrieve Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves a specific avatar by its ID. ```APIDOC ## GET /v1/avatars/{id} ### Description Retrieves a specific avatar by its ID. ### Method GET ### Endpoint /v1/avatars/{id} #### Path Parameters - **id** (string) - Required - The unique identifier of the avatar. ``` -------------------------------- ### client.workflowInvocations.retrieve(id) Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves a specific workflow invocation by its ID. This method allows you to fetch the details of a previously executed workflow. ```APIDOC ## GET /v1/workflow_invocations/{id} ### Description Retrieves a specific workflow invocation by its ID. ### Method GET ### Endpoint /v1/workflow_invocations/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the workflow invocation to retrieve. ### Response #### Success Response (200) - **WorkflowInvocationRetrieveResponse** (object) - Contains the details of the retrieved workflow invocation. ``` -------------------------------- ### Update Document Source: https://github.com/runwayml/sdk-node/blob/main/api.md Updates an existing document by its ID with the provided parameters. ```APIDOC ## PATCH /v1/documents/{id} ### Description Updates an existing document by its ID with the provided parameters. ### Method PATCH ### Endpoint /v1/documents/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the document to update. #### Request Body - **params** (object) - Required - Parameters for updating the document. ### Response #### Success Response (200) - **void** - Indicates successful update. ``` -------------------------------- ### Use Undocumented Request Parameters Source: https://github.com/runwayml/sdk-node/blob/main/README.md To use undocumented parameters, add `// @ts-expect-error` before the parameter. The library sends extra values as-is without runtime validation. ```typescript client.imageToVideo.create({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', }); ``` -------------------------------- ### client.tasks.delete Source: https://github.com/runwayml/sdk-node/blob/main/api.md Deletes a specific task by its ID. ```APIDOC ## DELETE /v1/tasks/{id} ### Description Deletes a specific task by its ID. ### Method DELETE ### Endpoint /v1/tasks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the task to delete. ### Response #### Success Response (200) - **void** - Indicates successful deletion. ``` -------------------------------- ### Retrieve Avatar Conversation Source: https://github.com/runwayml/sdk-node/blob/main/api.md Retrieves a specific avatar conversation by its ID. ```APIDOC ## GET /v1/avatar_conversations/{id} ### Description Retrieves a specific avatar conversation by its ID. ### Method GET ### Endpoint /v1/avatar_conversations/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the avatar conversation. ### Response #### Success Response (200) - **AvatarConversationRetrieveResponse** - The details of the retrieved avatar conversation. ``` -------------------------------- ### Cloudflare Workers tsconfig.json Configuration Source: https://github.com/runwayml/sdk-node/blob/main/MIGRATION.md Configure tsconfig.json for Cloudflare Workers. Include 'ES2020' in 'lib' and specify '@cloudflare/workers-types' in 'types'. ```json { "target": "ES2018", "lib": ["ES2020"], "types": ["@cloudflare/workers-types"] } ``` -------------------------------- ### client.realtimeSessions.delete Source: https://github.com/runwayml/sdk-node/blob/main/api.md Deletes a Realtime Session by its ID. This action terminates the specified session. ```APIDOC ## DELETE /v1/realtime_sessions/{id} ### Description Deletes a Realtime Session by its ID. ### Method DELETE ### Endpoint /v1/realtime_sessions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Realtime Session to delete. ### Response #### Success Response (200) - **void** - Indicates successful deletion with no content returned. ``` -------------------------------- ### Delete Document Source: https://github.com/runwayml/sdk-node/blob/main/api.md Deletes a specific document by its ID. ```APIDOC ## DELETE /v1/documents/{id} ### Description Deletes a specific document by its ID. ### Method DELETE ### Endpoint /v1/documents/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the document to delete. ### Response #### Success Response (200) - **void** - Indicates successful deletion. ``` -------------------------------- ### Avatars Delete Source: https://github.com/runwayml/sdk-node/blob/main/api.md Deletes a specific avatar by its ID. ```APIDOC ## DELETE /v1/avatars/{id} ### Description Deletes a specific avatar by its ID. ### Method DELETE ### Endpoint /v1/avatars/{id} #### Path Parameters - **id** (string) - Required - The unique identifier of the avatar. ``` -------------------------------- ### Delete Avatar Conversation Source: https://github.com/runwayml/sdk-node/blob/main/api.md Deletes a specific avatar conversation by its ID. ```APIDOC ## DELETE /v1/avatar_conversations/{id} ### Description Deletes a specific avatar conversation by its ID. ### Method DELETE ### Endpoint /v1/avatar_conversations/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the avatar conversation to delete. ### Response #### Success Response (200) - **void** - Indicates successful deletion. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.