Flows AI: Your Library for Building AI Workflows on Top of Vercel AI SDK

Today, we’re releasing Flows AI - a lightweight and minimal library for building agent workflows on top of Vercel AI SDK.

The Inspiration Behind Flows AI

The world of AI libraries often begins in Python. Yet despite its widespread adoption across cloud platforms, the JavaScript ecosystem still lacks a well-established, comparable solution for constructing agentic workflows. While libraries like Vercel AI SDK provide a great foundation, many solutions for orchestrating AI agents feel either overly complicated or underwhelming.

We ran down this rabbit hole last year with Fabrice - our first attempt at figuring out agentic systems at scale. The goal for Fabrice was simple: take workflow description in plain English, and by using available agents, plan and execute the work autonomously.

🎉 Meet Fabrice AI - functional framework for building AI agents.

While building Cali, I needed something stateless that can work on the server, inside CLI, breakdown complex tasks, and be simple.

Couldn't find one, so I built one. Give it a try! pic.twitter.com/YW6Bb8oFBc

— Mike (@grabbou) December 11, 2024

This abstraction showed two weak points when taken into production: non-deterministic behavior was hard to control in more complex workflows and it did not leverage existing tools, requiring you to design your system in a certain way.

Flows AI is designed to fill this gap, providing a minimalistic and functional mechanism to orchestrate AI agents. It is compatible with any LLM provider and SDK, and comes with everything you need to get started to build your first workflow - simple, or complex.

Getting Started

It is available on npm today:

npm install flows-ai --save

Here is everything you need to know.

Core Concepts: Flow and Agent

At its core, Flows AI treats agents as simple async functions that take an input and return an output. This design makes no assumptions about what happens inside each agent, providing maximum flexibility in your choice of tools and frameworks.

const weatherAgent = async (input) => {
// call an LLM, perform http request, or execute code locally
}

Agents, together with their input, create a flow, the fundamental unit of orchestration. A flow defines the operation to execute (via the agent) and the data it processes (via the input).

const weatherFlow = {
agent: 'weatherAgent',
input: 'What is weather in San Francisco?'
}

The shape of the input is specific to the agent. Most of the time, it is going to be a prompt that includes instructions for a given agent.

In this particular example, we could implement the weather agent as follows:

import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'
// input in this context is: "What is weather in San Francisco?"
const weatherAgent = async ({ input }) => {
const result = await generateText({
model: openai('gpt-4o'),
system: 'You are a weather forecast agent...',
tools: {
// tools to get weather etc.
},
prompt: input,
})
return result.text
})

Since we find ourselves prompting LLMs with Vercel AI SDK most of the time, we created a convenience helper to make it a bit easier:

import { agent } from 'flows-ai'
const weatherAgent = agent({
model: openai('gpt-4o'),
system: 'You are a weather forecast agent...',
tools: {
// tools to get weather etc.
},
})

It takes all same properties as Vercel AI SDK, with the only difference being maxSteps set to 10 as a sane default, so it acts more like an agent.

Executing Your Flow

All it takes is a simple function call to execute your flow:

import { execute } from 'flows-ai'
execute(weatherFlow, {
agents: {
weatherAgent
},
})
view raw your flow.js hosted with ❤ by GitHub

Since the flow definition itself is nothing but a fully serializable object, it does not contain agents as functions but rather as strings. Before your flow gets executed, we first hydrate it. Hence you must pass an object that contains a key-value map of available agents.

Executing the function takes a few more options, such as onFlowStart, that may turn out especially useful while debugging. Here’s more about the options.

Controlling Flow With Built-In Agents

We now know how to define and create a simple flow with an agent of your choice. If that was enough, however, we could stick to Vercel AI SDK and call it a day.

Let’s now have a look at how we can run multiple agents in parallel.

import { parallel } from 'flows-ai/flows'
const checkTemperatureFlow = parallel([
{
agent: 'weatherAgent',
input: 'What is weather in Wrocław tomorrow?'
},
{
agent: 'weatherAgent',
input: 'What is weather in Kraków tomorrow?'
}
])

In this example, we’re using one of the built-in control flow agents. We have modeled them after Anthropic’s article on building effective agents. In this case, we will run all sub-flows in parallel.

As mentioned at the beginning, flows can also be composed together to form more advanced flows together.

import { bestOf } from 'flows-ai/flows'
const tripPlanner = bestOf({
input: checkTemperatureFlow,
criteria: 'Best weather conditions, preferred no rain'
]}

In this case, we will pick the best city based on weather conditions that we have previously run in parallel.

You can learn more about this and other flows in the documentation.

Future

The AI space is moving quickly, and there are libraries created every day that explore new ways of building systems that involve AI agents. This one is no different.

First and foremost, we would like to get your feedback on whether our core principles and design decisions resonate well with the way you think about agentic systems.

Then, we would like to hear from you whether the provided built-in features cover a wide (and enough) spectrum of the most common use cases when building systems like this.

Overall, it’s a very exciting time right now and if you’re reading this - congrats, you’re on the bleeding edge, exploring how to get AI agents to scale! Let’s enjoy the journey while we get there.

Insights

Learn more about AI

Building a Software Factory: Write Specs an Agent Can Build From — cover

Nov 6Article

Building a Software Factory: Write Specs an Agent Can Build From

Learn how to research requirements, resolve open decisions, and write testable specs that AI coding agents can implement without the planning conversation.

 Large-Scale Migrations With Coding Agents: Planning, Verification, and Rollback — cover

Nov 4Article

Large-Scale Migrations With Coding Agents: Planning, Verification, and Rollback

Plan codebase migrations with coding agents using reviewable requirements, verification checks, staged rollouts, and defined rollback criteria.

Conversational Banking: From Customer Questions to Authorized Actions — cover

Nov 2Article

Conversational Banking: From Customer Questions to Authorized Actions

Explore conversational banking architecture through a card-dispute example, covering tool access, authorization, execution, observability, and human handoff.

Building a Software Factory: The Night My Agents Waited for Me — cover

Oct 28Article

Building a Software Factory: The Night My Agents Waited for Me

Learn how permissions, review limits, and missing product decisions stalled two overnight coding agent runs, and how their maintainer revised the workflow.

Your AI Coding Agent Still Needs an Architecture — cover

Oct 22Article

Your AI Coding Agent Still Needs an Architecture

Use explicit contracts, behavior tests, and dependency checks to guide AI coding agents and review their changes through a TypeScript favorites example.

cover

Oct 15Live Stream

Who Left the Agents Running? React Native Software Factories

Join Kewin Wereszczyński and Szymon Chmal to explore what can go wrong in a React Native software factory overnight and the controls that keep agents on track.

cover

Oct 14Podcast

When Coding Gets Faster, What Breaks Next?

Matt Hargett explains how AI moves bottlenecks across testing, deployment, infrastructure, support, and the rest of software delivery.

cover

Oct 12Podcast

AI Coding Agents and Hermes With Tzvetan Mikov

Tzvetan Mikov discusses AI coding agents, context switching, low-level engine optimization, reviewing specs and tests, and his plans for Hermes X.

cover

Oct 12Podcast

State Machines for AI Agents With David Khourshid

David Khourshid explains state machines for AI agents, human approval steps, tracing, and handling invalid model outputs in agent workflows.

cover

Oct 9Article

How to Maximize AI SDLC? Measure the Outer Business Loop, Not the Inner Developer Loop

Connect AI-assisted development to measurable business outcomes. Matt Hargett shares a checklist for assessing user exposure, results, and delivery costs.

cover

Oct 7Talk

Automating Mobile QA with Cloud Agents

Michał Pierzchała shows how cloud-based QA agents can test real iOS and Android user flows and bring screenshots, recordings, and logs into pull requests.

cover

Oct 1Live Stream

Can Jev Make AI Agent Decisions Faster?

Explore Jev with Kewin Wereszczyński and Szymon Chmal: how it works, its approach to faster agent decisions, and possible local alternatives.

cover

Mar 19Tutorial

The Hard Way vs. The React Native AI SDK Way: Stop Writing Custom Modules for Every Model

Learn how React Native AI uses a unified provider model to switch between cloud and on-device LLMs without rewriting application logic, enabling reliable AI experiences online and offline.

cover

Mar 12Tutorial

Build Smarter Apps: Tool Calling & AI Orchestration Explained

Learn how on-device models in React Native can call tools, interact with external APIs, and return structured outputs you can use directly in application logic.

cover

Mar 5Tutorial

MLC LLM + React Native: On-Device AI Without the Pain

Learn how to run third-party on-device LLMs in React Native using MLC LLM. Choose your models, run them efficiently across platforms, and keep a unified JavaScript API with React Native AI.

cover

Feb 24Tutorial

Intelligent Fallbacks with Apple Intelligence in React Native

Learn how to use Apple’s built-in Foundation Models in React Native apps, reduce memory usage, and enable fast, fully on-device AI with React Native AI Apple.

cover

Feb 10Tutorial

What Is the React Native AI SDK? A Complete Intro & Quickstart

Learn why on-device AI matters for React Native apps, how local LLMs behave offline, and what problems React Native AI is designed to solve from day one.

cover

Jan 29Tutorial

Implementing an Android TurboModule with Kotlin

Learn how to implement a React Native TurboModule on Android, from the TypeScript spec and Codegen to the Kotlin implementation and package registration.

cover

Jan 19Tutorial

Working with Different Threads in Swift TurboModules

Learn how JavaScript, native module, background, and main threads interact in React Native TurboModules, and how to use GCD queues to run async work safely in Swift.

cover

Jan 9Tutorial

How to Add Type-Safe Constants to Swift TurboModules

Learn how to expose typed, immutable constants from a Swift TurboModule using Codegen, and get full end-to-end type safety between native and JavaScript.

cover

Dec 30Tutorial

Adding Event Emitters to Your TurboModule in Swift

Learn how to emit native events from a Swift TurboModule and subscribe to them in JavaScript, including proper memory management and Codegen integration.

cover

Dec 22Tutorial

Writing Your First TurboModule in Swift

Learn how to build a fully working TurboModule in Swift, integrate it with Codegen, and bridge it through Objective‑C inside an Expo app.