Interface FalClient

The main client type, it provides access to simple API model usage, as well as access to the queue and storage APIs.

createFalClient

interface FalClient {
    queue: QueueClient;
    realtime: RealtimeClient;
    storage: StorageClient;
    stream: (<Output, Input>(endpointId: string, options: StreamOptions<Input>) => Promise<FalStream<Input, Output>>);
    streaming: StreamingClient;
    run<Output, Input>(endpointId: string, options: RunOptions<Input>): Promise<Result<Output>>;
    subscribe<Output, Input>(endpointId: string, options: RunOptions<Input> & QueueSubscribeOptions): Promise<Result<Output>>;
}

Properties

The queue client to interact with the queue API.

realtime: RealtimeClient

The realtime client to interact with the realtime API and receive updates in real-time.

  • #RealtimeClient
  • #RealtimeClient.connect
storage: StorageClient

The storage client to interact with the storage API.

stream: (<Output, Input>(endpointId: string, options: StreamOptions<Input>) => Promise<FalStream<Input, Output>>)

Calls a fal app that supports streaming and provides a streaming-capable object as a result, that can be used to get partial results through either AsyncIterator or through an event listener.

Type declaration

    • <Output, Input>(endpointId, options): Promise<FalStream<Input, Output>>
    • Calls a fal app that supports streaming and provides a streaming-capable object as a result, that can be used to get partial results through either AsyncIterator or through an event listener.

      Type Parameters

      • Output = any
      • Input = Record<string, any>

      Parameters

      • endpointId: string

        the endpoint id, e.g. fal-ai/llavav15-13b.

      • options: StreamOptions<Input>

        the request options, including the input payload.

      Returns Promise<FalStream<Input, Output>>

      the FalStream instance.

the endpoint id, e.g. fal-ai/llavav15-13b.

the request options, including the input payload.

the FalStream instance.

streaming: StreamingClient

The streaming client to interact with the streaming API.

#stream

Methods

  • Subscribes to updates for a specific request in the queue.

    Type Parameters

    • Output = any
    • Input = Record<string, any>

    Parameters

    • endpointId: string

      The ID of the API endpoint.

    • options: RunOptions<Input> & QueueSubscribeOptions

      Options to configure how the request is run and how updates are received.

    Returns Promise<Result<Output>>

    A promise that resolves to the result of the request once it's completed.