Function helps you run stateless Python functions (a.k.a “predictors”) on-device. Features include:

  • Cross platform: Function supports compiling and running Python functions across Android, iOS, macOS, Linux, Windows, and the browser.
  • Zero dependencies: Function compiles these prediction functions into self-contained binaries, meaning you can make predictions with zero dependencies.
  • Hardware acceleration: Function is designed to use all available compute acceleration hardware (e.g. GPU, NPU) and instruction sets (e.g. CoreML, DirectML, CUDA).

Installing Function

We provide SDKs for common development environments:

# Run this in Terminal
$ npm install fxnjs

Most of our client SDKs are open-source. Star them on GitHub!

Creating an Access Key

Head over to Function to create an account by logging in. Once you do, generate an access key:

create key

Making your First Prediction

Let’s run the @fxn/greeting predictor which accepts a name and returns a friendly greeting:

import { Function } from "fxnjs"

// 💥 Create your Function client
const fxn = new Function({ accessKey: "..." });

// 🔥 Make a prediction
const prediction = await fxn.predictions.create({
  tag: "@fxn/greeting",
  inputs: { name: "Yusuf" }
});

// 🚀 Print the result
console.log(prediction.results[0]);

You should see a friendly greeting. Congrats on your first prediction 🎉

Join our waitlist to bring your custom Python functions and run them on-device.