OpenForm
AI

TanStack AI

Last updated on

Use OpenForm tools with TanStack AI

@open-form/tanstack-ai wraps @open-form/ai-tools with TanStack AI's toolDefinition().server() pattern. Tools run server-side and work with TanStack AI's chat, agent, and server handler APIs.

Installation

npm install @open-form/tanstack-ai @tanstack/ai zod

Peer dependencies: @tanstack/ai and zod ^4.0.0.

Usage

import { openFormTools } from "@open-form/tanstack-ai"

const tools = openFormTools({
  defaultRegistryUrl: "https://public.open-form.dev",
})

// Use with TanStack AI's chat, agent, or server handler

Composing with other tools

Spread alongside your own tools:

import { openFormTools } from "@open-form/tanstack-ai"
import { toolDefinition } from "@tanstack/ai"
import { z } from "zod"

const lookupCustomer = toolDefinition({
  name: "lookupCustomer",
  description: "Look up a customer by ID",
  inputSchema: z.object({ id: z.string() }),
}).server(async ({ id }) => fetchCustomer(id))

const allTools = {
  ...openFormTools(),
  lookupCustomer,
}

Or pick individual tools:

const { validateArtifact, render } = openFormTools()

Configuration

openFormTools({
  defaultRegistryUrl: "https://public.open-form.dev",
  proxyTextRenderer: {
    url: "https://your-documents-service.example.com",
    apiKey: "your-api-key",
  },
  fetch: customFetchWithAuth,
})

See the configuration reference for details on each option.

API

openFormTools(config?)

Returns an object with five server tools:

KeyTool nameDescription
validateArtifactvalidateArtifactValidates an OpenForm artifact against its schema
fillfillFills an OpenForm artifact with data and validates
renderrenderRenders an OpenForm artifact to PDF, markdown, or DOCX
getRegistrygetRegistryFetches registry.json from a URL, returns available artifacts
getArtifactgetArtifactFetches artifact JSON from a registry by name

Re-exports

The package also re-exports all output types from @open-form/ai-tools:

import type {
  OpenFormToolsConfig,
  ProxyTextRendererConfig,
  ValidateOutput,
  FillOutput,
  RenderOutput,
  GetRegistryOutput,
  GetArtifactOutput,
} from "@open-form/tanstack-ai"

On this page