Documentation
SDK

SDK Overview

Install and configure @flapjack/sdk β€” the TypeScript client and React hooks for embedding Flapjack AI agents in your product.

@flapjack/sdk is the TypeScript SDK for embedding Flapjack agents in your product. It includes a client for programmatic access and React hooks for building chat UIs.

Installation

npm install @flapjack/sdk
πŸ“‹ Copy as prompt

Install the Flapjack SDK: npm install @flapjack/sdk

Package Exports

Import PathWhat It Provides
@flapjack/sdkFlapjackClient, all TypeScript types
@flapjack/sdk/reactFlapjackProvider, useChat, usePlan hooks
@flapjack/sdk/componentsPre-built UI: ChatPanel, FloatingChat, PlanPanel, and more

Configuration

import { FlapjackClient } from '@flapjack/sdk';

const client = new FlapjackClient({
  apiKey: process.env.FLAPJACK_API_KEY!,
  baseUrl: process.env.FLAPJACK_BASE_URL, // optional
});
πŸ“‹ Copy as prompt

Create a FlapjackClient instance using my API key from the FLAPJACK_API_KEY environment variable.

FlapjackConfig

FieldTypeRequiredDefaultDescription
apiKeystringYesβ€”Your API key (fj_live_...)
baseUrlstringNohttps://api.flapjack.devAPI base URL
type FlapjackConfig = {
  apiKey: string;
  baseUrl?: string;
};

Error Handling

SDK methods throw standard Error objects on failure. The error message contains the error code from the API:

try {
  const agents = await client.listAgents();
} catch (error) {
  console.error('Failed:', error.message);
  // e.g., "UNAUTHORIZED", "NOT_FOUND", "HTTP 500"
}

For streaming (sendMessage), errors are yielded as events instead of thrown:

for await (const event of client.sendMessage(threadId, 'Hello')) {
  if (event.type === 'error') {
    console.error('Stream error:', event.code, event.detail);
  }
}
πŸ“‹ Copy as prompt

Add error handling to my Flapjack SDK calls. Wrap non-streaming methods in try/catch, and check for error events in the sendMessage stream.

TypeScript Types

All types are exported from @flapjack/sdk:

import type {
  Agent,
  Thread,
  Message,
  ChatEvent,
  KnowledgeDoc,
  FlapjackConfig,
  // Tool types
  ToolDef,
  ToolCall,
  ToolResult,
  // Feature configs
  WebConfig,
  MemoryConfig,
  PlanConfig,
  ComputerConfig,
  // Plans
  Plan,
  PlanTodo,
  // MCP & Integrations
  McpServer,
  Integration,
  AgentMcp,
  AgentIntegration,
  // Analytics
  AnalyticsResult,
  // Multiplayer
  MultiplayerConfig,
  ThreadParticipant,
  // Marketplace
  MarketplaceProfile,
  MarketplaceCapability,
  // Runners
  Runner,
  RunnerStep,
  RunnerTrigger,
  RunnerRun,
  RunnerAnalytics,
} from '@flapjack/sdk';

See SDK: Client for full type definitions.

Sections

Docs last updated May 11, 2026