A small library for interfacing with RunwayML Hosted Models using only a few lines of code. Works in both Node.js and the Browser.
This library is a thin wrapper around the Hosted Models HTTP API. It provides a few benefits:
- Abstracts the HTTP requests to the Hosted Model, so you don't have to make them directly.
- Simplifies authorization for private models, just provide your
token
in thenew HostedModels({ url, token })
constructor. - Automatically retries failed requests if they timed out while the model wakes up or are blocked due to rate-limiting.
- Includes friendly error reporting with messages for humans, so you can better understand why something went wrong.
If your project is written in JavaScript, we encourage you to use this library!
If you are using Node.js or packaging your front-end code via a bundler, you can install the module using npm
.
npm install --save @runwayml/hosted-models
const { HostedModel } = require('@runwayml/hosted-models')
const model = new HostedModel({
url: 'https://my-model.hosted-models.runwayml.com/v1'
token: 'my-private-hosted-model-token'
})
const prompt = "Hey text generation model, finish my sentence"g
model.query({ prompt }).then(result => console.log(result))
If you prefer to access the library in the Browser using a <script>
tag, you can include the code snippet below in your HTML files.
<!--
You can replace hosted-models.min.js with hosted-models.js to use the non-minified version if you prefer
-->
<script src="https://cdn.jsdelivr.net/npm/@runwayml/hosted-models@latest/dist/hosted-models.min.js"></script>
This injects the library into the window and exposes it via the rw
namespace.
const model = new rw.HostedModel({
url: 'https://my-model.hosted-models.runwayml.com/v1'
token: 'my-private-hosted-model-token'
})
const prompt = "Hey text generation model, finish my sentence"
model.query({ prompt }).then(result => console.log(result))
This library is released under the terms of the MIT license.