FluxyChat

Guides

AI Tool Presets

`createChatTools()` generates a set of AI SDK-compatible tools for chat operations (fetching messages, posting, reactions, etc.) with preset-based filtering and

AI Tool Presets

createChatTools() generates a set of AI SDK-compatible tools for chat operations (fetching messages, posting, reactions, etc.) with preset-based filtering and approval controls.

Usage

import { createChatTools } from "@fluxy-chat/sdk";

const chat: ChatBinding = {
  thread(id) { /* ... */ },
  channel(id) { /* ... */ },
  getUser(id) { /* ... */ },
  openDM(id) { /* ... */ },
};

const tools = createChatTools({ chat, preset: "reader" });

// Pass to AI SDK
const result = await streamText({
  model: openai("gpt-4"),
  tools,
});

Presets

PresetToolsDescription
reader7Read-only: fetch messages, threads, users
messenger10Read + post + reactions + typing
moderator17Full set including edit, delete, subscriptions

Approval

Write tools (post, edit, delete, react, subscribe) default to needsApproval: true:

createChatTools({
  chat,
  preset: "messenger",
  requireApproval: { postMessage: false },  // override specific tools
});

Overrides

Customize tool descriptions or other non-core fields:

createChatTools({
  chat,
  preset: "reader",
  overrides: {
    fetchMessages: { description: "Custom description" },
  },
});

Protected fields (execute, parameters) cannot be overridden.

Tool Definitions

Each tool exports description, parameters (JSON Schema), execute function, and optional needsApproval flag. Compatible with Vercel AI SDK, OpenAI, Anthropic, and other tool-calling APIs.

See Also

On this page