Skip to main content

AI in Stof

@formata/ai is built into Stof (0.14 and later): it calls models, runs #[tool] functions and MCP servers' tools in agents, and runs hooks around every model call and tool call, so a pricing or policy layer can meter, route, and allow them. It's plain Stof, so it works the same in Rust, the browser, Node, and Python, and every provider has one shape: requests, responses, events, usage, and errors.

These guides go by task. The package's README is the reference: every field, function, event, and error.

GuideWhat it covers
Getting startedLoading the package, a first call with no key, a real provider, streaming, and an agent
ProvidersOpenAI, Anthropic, compatible servers and local models, keys, options, retries, and fallback
Tools and agents#[tool] functions, running tool calls, agents and their limits, and skills
IntentsFunctions declared by what they should do, written by a model in a sandbox and checked by your examples and checks
HooksMetering, budgets, routing, and tool approval around every call (how Limitr connects)
MCP serversRemote MCP servers' tools, resources, and prompts, and logging in with OAuth
HostsCalling from TypeScript, Python, and Rust, events to a UI, and providers the host runs