Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HostedModel

A class representing a Runway Hosted Model. This is the main interface provided by this package. Exposes two main methods for interfacing with a model.

  • info()
  • query(input)

Exposes two helper methods for checking the "awake" status of a hosted model.

  • isAwake()
  • waitUntilAwake()

Hierarchy

  • HostedModel

Index

Constructors

constructor

  • const model = new HostedModel({
     url: 'https://my-model.hosted-models.runwayml.cloud/v1',
     token: 'my-secret-token', # token is only required for private models
    })

    Parameters

    Returns HostedModel

Properties

Private headers

headers: {}

Type declaration

  • [name: string]: string

Private responseCodesToRetry

responseCodesToRetry: number[]

Private token

token: string

Private url

url: string

Methods

info

  • info(): Promise<any>
  • Return info about the input/output spec provided by the model. Makes a GET request to the /v1/info route of a hosted model under the hood.

    Returns Promise<any>

isAwake

  • isAwake(): Promise<boolean>

Private isHostedModelResponseError

  • isHostedModelResponseError(response: AxiosResponse): boolean

Private isValidV1URL

  • isValidV1URL(url: string): boolean

query

  • query(input: any): Promise<any>
  • Run the model on your input and produce an output. This is how you "run" the model.

    Parameters

    • input: any

      An object containing input parameters to be sent to the model. Use the info method to get the correct format for this object, as each model expects different inputs.

    Returns Promise<any>

Private requestHostedModel

  • requestHostedModel(config: AxiosRequestConfig): Promise<any>

Private root

  • root(): Promise<any>

waitUntilAwake

  • waitUntilAwake(pollIntervalMillis?: number): Promise<void>
  • Returns a promise that will resolve once the model is awake. This method is never required, as info and query will always return results eventually, but it can be useful for managing UI if you want to postpone making info and query requests until you know that they will resolve more quickly.

    // This is pseudo code
    const model = new HostedModel({
     url: 'https://my-model.hosted-models.runwayml.cloud/v1',
     token: 'my-secret-token', # token is only required for private models
    })
    // Enter some loading state in the UI.
    loading(true)
    await model.waitUntilAwake() // This method is never required, but can sometimes be useful
    loading(false)
    
    while (true) {
     const input = getSomeInput()
     const output = await model.query(input)
     doSomething(output)
    }

    Parameters

    • Default value pollIntervalMillis: number = 1000

      waitUntilAwake The rate that this function will poll the hosted model endpoint to check if it is awake yet.

    Returns Promise<void>

Generated using TypeDoc