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 🙏

© 2025 – Pkg Stats / Ryan Hefner

clarifai-node-serverless

v0.1.0

Published

![image](https://github.com/user-attachments/assets/3721189c-01c0-4936-a73c-13dcbf808542)

Downloads

13

Readme

image

npm Build Discord

Clarifai Node.js SDK - For Serverless Environments

This is the official Node.js client library for working with Clarifai's API in serverless environments. This library is designed to be lightweight, compatible with modern ESM syntax, and optimized for serverless platforms like AWS Lambda, Vercel, and Netlify.

This library currently includes only a small subset of features from the main Clarifai Node.js SDK package. We are actively working on adding more features and improvements. If you need a specific feature, please let us know by opening an issue or joining our Discord community.

Website | Schedule Demo | Signup for a Free Account | API Docs | Clarifai Community | Discord

Give the repo a star ⭐

Installation

npm install clarifai-node-serverless

Usage

Clarifai uses Personal Access Tokens(PATs) to validate requests. You can create and manage PATs under your Clarifai account security settings.

  • 🔗 Create PAT: Log into Portal → Profile Icon → Security Settings → Create Personal Access Token → Set the scopes → Confirm

Export your PAT as an environment variable. Then, import and initialize the API Client.

Set PAT as environment variable through terminal:

export CLARIFAI_PAT={your personal access token}

or use dotenv to load environment variables via a .env file

Using Workflows

import { Workflow, getInputFromUrl } from "clarifai-node-serverless";

const GENERAL_WORKFLOW =
  "https://clarifai.com/my-org/celebrity-check/workflows/General";

const CELEBRITY_IMAGE = "https://samples.clarifai.com/celebrity.jpeg";

const workflow = new Workflow({
  url: GENERAL_WORKFLOW,
  authConfig: {
    pat: process.env.CLARIFAI_PAT!,
  },
});

const input = getInputFromUrl({
  url: CELEBRITY_IMAGE,
  inputType: "image",
});

const response = await workflow.predict({
  inputs: [input],
});

console.log(response);

Using Clarifai GRPC directly

If you were previously using the clarifai-nodejs-grpc package or you want to access the full range of Clarifai API features, you can use the GRPC client directly.

import {
  PostModelOutputsRequest,
  V2Client,
} from "clarifai-node-serverless/grpc/proto/clarifai/api/service";
import { ChannelCredentials, Metadata } from "@grpc/grpc-js";
import { StatusCode } from "clarifai-node-serverless/grpc/proto/clarifai/api/status/status_code";

const client = new V2Client(
  "api.clarifai.com:443",
  ChannelCredentials.createSsl(),
);

const postModelOutputsRequest = PostModelOutputsRequest.fromPartial({
  modelId: "aaa03c23b3724a16a56b629203edc62c",
  inputs: [
    {
      data: {
        image: {
          url: "https://samples.clarifai.com/dog2.jpeg",
        },
      },
    },
  ],
});

const metadata = new Metadata();
metadata.set("authorization", `key ${process.env.CLARIFAI_PAT}`);

client.postModelOutputs(postModelOutputsRequest, metadata, (err, response) => {
  if (err) {
    console.log("Error: " + err);
    return;
  }

  if (response?.status?.code !== StatusCode.SUCCESS) {
    console.log(
      "Received failed status: " +
        response?.status?.description +
        "\n" +
        response?.status?.details,
    );
    return;
  }

  console.log("results:");
  console.log(response?.outputs);
});