npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fal-ai/client

v1.1.3

Published

The fal.ai client for JavaScript and TypeScript

Downloads

17,836

Readme

fal.ai JavaScript/TypeScript client library

@fal-ai/client npm package

Introduction

The fal.ai JavaScript Client Library provides a seamless way to interact with fal endpoints 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.

Getting started

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

import { fal } from "@fal-ai/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 journey with fal.ai. Dive into the official documentation for a comprehensive guide.