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: (<Id>(endpointId: Id, options: StreamOptions<InputType<Id>>) => Promise<FalStream<InputType<Id>, OutputType<Id>>>);
    streaming: StreamingClient;
    run<Id>(endpointId: Id, options: RunOptions<InputType<Id>>): Promise<Result<OutputType<Id>>>;
    subscribe<Id>(endpointId: Id, options: RunOptions<InputType<Id>> & QueueSubscribeOptions): Promise<Result<OutputType<Id>>>;
}

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: (<Id>(endpointId: Id, options: StreamOptions<InputType<Id>>) => Promise<FalStream<InputType<Id>, OutputType<Id>>>)

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

    • <Id>(endpointId, options): Promise<FalStream<InputType<Id>, OutputType<Id>>>
    • 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

      • Id extends EndpointType

      Parameters

      • endpointId: Id

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

      • options: StreamOptions<InputType<Id>>

        the request options, including the input payload.

      Returns Promise<FalStream<InputType<Id>, OutputType<Id>>>

      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

  • Runs a fal endpoints identified by its endpointId.

    Type Parameters

    • Id extends EndpointType

    Parameters

    • endpointId: Id

      the registered function revision id or alias.

    • options: RunOptions<InputType<Id>>

    Returns Promise<Result<OutputType<Id>>>

    the remote function output

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

    Type Parameters

    • Id extends EndpointType

    Parameters

    • endpointId: Id

      The ID of the API endpoint.

    • options: RunOptions<InputType<Id>> & QueueSubscribeOptions

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

    Returns Promise<Result<OutputType<Id>>>

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