Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fal-ai/serverless-client

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fal-ai/serverless-client

Deprecation note: this library has been deprecated in favor of @fal-ai/client

  • 0.15.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-26.21%
Maintainers
1
Weekly downloads
 
Created
Source

fal.ai JavaScript/TypeScript client library

@fal-ai/serverless-client npm package

Introduction

The fal.ai JavaScript Client Library provides a seamless way to interact with fal serverless functions from your JavaScript or TypeScript applications. With built-in support for various platforms, it ensures consistent behavior across web, Node.js, and React Native environments.

[!WARNING] This dependency was deprecated in favor of the official 1.0.0 release, renamed to @fal-ai/client. Please update your dependencies to the new package.

Getting started

Before diving into the client-specific features, ensure you've set up your credentials:

import * as fal from "@fal-ai/serverless-client";

fal.config({
  // Can also be auto-configured using environment variables:
  // Either a single FAL_KEY or a combination of FAL_KEY_ID and FAL_KEY_SECRET
  credentials: "FAL_KEY_ID:FAL_KEY_SECRET",
});

Note: Ensure you've reviewed the fal.ai getting started guide to acquire your credentials and register your functions. Also, make sure your credentials are always protected. See the ../proxy package for a secure way to use the client in client-side applications.

Running functions with fal.run

The fal.run method is the simplest way to execute a function. It returns a promise that resolves to the function's result:

const result = await fal.run("my-function-id", {
  input: { foo: "bar" },
});

Long-running functions with fal.subscribe

The fal.subscribe method offers a powerful way to rely on the queue system to execute long-running functions. It returns the result once it's done like any other async function, so your don't have to deal with queue status updates yourself. However, it does support queue events, in case you want to listen and react to them:

const result = await fal.subscribe("my-function-id", {
  input: { foo: "bar" },
  onQueueUpdate(update) {
    if (update.status === "IN_QUEUE") {
      console.log(`Your position in the queue is ${update.position}`);
    }
  },
});

More features

The client library offers a plethora of features designed to simplify your serverless journey with fal.ai. Dive into the official documentation for a comprehensive guide.

Keywords

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc