An open API service indexing awesome lists of open source software.

https://github.com/joggrdocs/funkai

A composable AI microframework built on ai-sdk, curried with funk-tional programming flair.
https://github.com/joggrdocs/funkai

agents ai ai-sdk functional-programming microframework nodejs prompts typescript vercel-ai-sdk workflows

Last synced: 4 days ago
JSON representation

A composable AI microframework built on ai-sdk, curried with funk-tional programming flair.

Awesome Lists containing this project

README

          


funkai

A composable AI microframework built on ai-sdk, curried with funk-tional programming flair.

CI
npm version
License

## Features

- :zap: **Functions all the way down** — `agent`, `tool`, `flowAgent` are functions returning plain objects.
- :jigsaw: **Composition over configuration** — Combine small pieces instead of configuring large ones.
- :shield: **Result, never throw** — Every public method returns `Result`.
- :lock: **Closures are state** — Flow agent state is just variables in your handler.
- :triangular_ruler: **Type-driven design** — Zod schemas, discriminated unions, exhaustive matching.

## Install

```bash
npm install @funkai/agents @funkai/prompts
```

## Usage

### Create an agent

```ts
import { agent } from "@funkai/agents";
import { openai } from "@ai-sdk/openai";

const writer = agent({
name: "writer",
model: openai("gpt-4.1"),
system: "You are a helpful writer.",
tools: { search },
});

const result = await writer.generate({ prompt: "Write about closures" });
```

### Define a prompt

```
---
name: writer
schema:
tone: string
---
You are a {{ tone }} writer.
```

### Generate typed prompts

```bash
npx funkai prompts generate --out .prompts/client --includes "src/agents/**"
```

## Packages

| Package | Description |
| ------------------------------------- | -------------------------------------------------------------------- |
| [`@funkai/agents`](packages/agents) | Lightweight agent, tool, and flow agent orchestration |
| [`@funkai/models`](packages/models) | Model catalog, provider resolution, and cost calculations |
| [`@funkai/prompts`](packages/prompts) | Prompt SDK with LiquidJS templating, Zod validation, and CLI codegen |
| [`@funkai/cli`](packages/cli) | CLI for the funkai prompt SDK |

## License

[MIT](LICENSE)