Skip to main content

Overview

This quickstart will guide you through building a simple AI-powered application using FF. You’ll create an Effect.ts program that:
  1. Uses the AI SDK wrapper to generate text with typed callbacks
  2. Implements a tool with Effect.ts patterns
  3. Logs structured output with Effect’s logging
By the end, you’ll understand how FF brings type safety and composability to AI development.

Prerequisites

Before starting, ensure you have:
  • Node.js 18+ or Bun 1.0+ installed
  • An OpenAI API key (or another AI SDK-compatible provider)
This guide uses OpenAI, but FF works with any AI SDK provider (Anthropic, Google, etc.)

Step 1: Install Dependencies

1

Create a new project

2

Install FF and dependencies

3

Set up TypeScript

Update your tsconfig.json:

Step 2: Create Your First Effect Program

Create a file called index.ts:
index.ts

Step 3: Add Environment Variables

Create a .env file:
.env
Update index.ts to load environment variables:
Install dotenv:

Step 4: Run Your Application

You should see output like:

Understanding the Code

Let’s break down what makes this FF code special:

Effect.ts Integration

FF wraps AI SDK functions as Effects, allowing you to compose them with other Effect operations like logging, error handling, and service access.

Typed Callbacks

Unlike AI SDK’s Promise-based callbacks, FF callbacks return Effects. This gives you:
  • Access to Effect services and context
  • Structured error handling
  • Type-safe composition with other Effects
  • Automatic fiber management

Tool Definition

Tools execute as Effects, enabling:
  • Database queries with Effect services
  • Error handling with typed errors
  • Logging and telemetry
  • Access to your application context

Next Steps

Add Database Operations

Combine FF’s AI wrappers with Drizzle ORM:
See the ff-effect Drizzle guide for details.

Manage Conversations

Add persistent conversation history with ff-ai:
See the ff-ai guide for conversation management.

Build HTTP Services

Create HTTP endpoints that serve AI responses:
See the ff-serv guide for HTTP utilities.

Learn More

Explore the full capabilities of each package:

ff-effect

AI SDK, Drizzle, Inngest, and oRPC wrappers

ff-ai

Conversation management and persistence

ff-serv

HTTP services, logging, and caching

Common Patterns

Error Handling

Service Integration

Concurrent Operations

Get Help

Need assistance?