Ship tool-calling agents
without the guesswork
A provider-agnostic TypeScript SDK for tool-calling agents — session memory, multi-agent handoffs, guardrails, and real-time execution tracing, out of the box.
| 1 | import { generateText } from "chai-ai"; |
| 2 | import { google } from "@chai-ai/google"; |
| 3 | |
| 4 | const { text } = await generateText({ |
| 5 | model: google("gemini-3.1-pro-preview"), |
| 6 | prompt: "Explain quantum entanglement in simple terms.", |
| 7 | }); |
| 8 | |
| 9 | console.log(text); |
This is what a real run looks like.
A handoff, a guardrail requiring approval, and a tool call — the exact events your code sees from agent.stream(), replayed at real timing.
How Autonomous Runs Work
Initial Reasoning & Intent Analysis
The primary support agent evaluates instructions and determines that the query requires specialized billing domain knowledge.
// Model reasons over supportAgent's instructions // and decides this needs the billing specialist // -> calls the synthetic transfer_to_billing tool
Everything you need for production AI agents.
Zero vendor lock-in, strict type safety, human-in-the-loop controls, and structured tracing out of the box.
Multi-Model Provider Adapters
Switch LLM backends without rewriting core application logic.
Policy Guardrails
Human-in-the-loop safety & approval gates.
Session Memory
Immutable agent configuration separated cleanly from multi-turn session state.
Zod Schema Validation
Pass a Zod schema and receive fully validated, typed objects instead of free text.
Full Tracing
Every run returns structured steps, model calls, latency metrics, and tool logs.
Three providers today. Any model is a LanguageModel away.
@chai-ai/openai, @chai-ai/google, and @chai-ai/anthropic wrap the official vendor SDKs. They all implement the same public LanguageModel interface that Agent accepts — write one for any other provider without touching the core.