Skip to main content
The SuperDoc SDK ships tool definitions that plug directly into OpenAI, Anthropic, Vercel AI, or any custom LLM integration. Pick tools, send them with your prompt, dispatch the model’s tool calls — the SDK handles schema formatting, argument validation, and execution.
LLM tools are in alpha. Tool names and schemas may change between releases.

Quick start

Install the SDK, create a client, and wire up an agentic loop.

Tool selection

chooseTools() returns provider-formatted tool definitions ready to pass to your LLM.

Essential mode (default)

Returns 5 essential tools plus discover_tools — a meta-tool that lets the LLM load more groups on demand. This keeps the initial context small while giving the model access to the full toolkit when needed. The 5 essential tools: If you pass groups, those groups are loaded in addition to the essential set:

All mode

Returns every tool from the requested groups (or all groups if groups is omitted). The core group is always included.

Dispatching tool calls

dispatchSuperDocTool() resolves a tool name to the correct SDK method, validates arguments, and executes the call.
The dispatcher validates required parameters, enforces mutual exclusivity constraints, and throws descriptive errors if arguments are invalid — so the LLM gets actionable feedback.

Tool groups

Tools are organized into 11 groups. In essential mode, the LLM can load any group dynamically via discover_tools.

The discover_tools pattern

When the LLM needs tools beyond the essential set, it calls discover_tools with the groups it wants. Your agentic loop handles this like any other tool call — dispatchSuperDocTool returns the new tool definitions, and you merge them into the next request.

Providers

Each provider gets tool definitions in its native format.

Best practices

Start with essential mode

Load only the 5 essential tools plus discover_tools. This keeps the context window small and gives the model room to reason. Let it call discover_tools when it needs more — don’t front-load every group.

Minimize tool calls

A typical edit should take 3–5 tool calls: query, mutate, done. Instruct the LLM to plan all edits before calling tools, and to batch multiple changes into a single apply_mutations call when possible.

Use apply_mutations for text edits

apply_mutations can rewrite, insert, delete, and format text in one call. It supports multiple steps, so the LLM can edit several paragraphs at once. Use it for any operation on existing text.

Feed errors back to the model

dispatchSuperDocTool throws descriptive errors with codes like MATCH_NOT_FOUND or INVALID_ARGUMENT. Pass these back as tool results — most models self-correct on the next turn.

Add tool call examples for repeatable actions

If your workflow involves the same kind of edit across many documents (e.g., always rewriting a specific clause, always adding a comment to a section), include a concrete tool call example in your system prompt. Models that see a working example of the exact tool invocation produce correct calls more reliably than models that only see the schema.

Include a system prompt

Tell the model what it can do and how to approach edits. Here’s an example:

Utility functions

  • MCP Server — connect AI agents via the Model Context Protocol
  • Skills — reusable prompt templates for LLM document editing
  • SDKs — typed Node.js and Python wrappers
  • Document API — the operation set behind the tools
  • AI Agents — headless mode for server-side AI workflows