Chai AI SDKv0.2.0

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.

1import { generateText } from "chai-ai";
2import { google } from "@chai-ai/google";
3
4const { text } = await generateText({
5 model: google("gemini-3.1-pro-preview"),
6 prompt: "Explain quantum entanglement in simple terms.",
7});
8
9console.log(text);
Interactive Output
200 OK
Explain quantum entanglement in simple terms.
chai-ai / agentmodel: google

142ms response timerun complete
Not a mockup

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.

streaming live…
Interactive Architecture

How Autonomous Runs Work

Live Agent Pipeline
Model Requests Handoff

Initial Reasoning & Intent Analysis

The primary support agent evaluates instructions and determines that the query requires specialized billing domain knowledge.

Step 2 of 5
agent-flow-trace.tsTypeScript
// Model reasons over supportAgent's instructions
// and decides this needs the billing specialist
// -> calls the synthetic transfer_to_billing tool
Built for Production

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.

model: google("gemini-3.1-pro-preview")

Policy Guardrails

Human-in-the-loop safety & approval gates.

deleteDatabase()
Fails closed if unapprovedFails Closed

Session Memory

Immutable agent configuration separated cleanly from multi-turn session state.

session.getMessages() → 4 messages

Zod Schema Validation

Pass a Zod schema and receive fully validated, typed objects instead of free text.

outputSchema: z.object({ ... })

Full Tracing

Every run returns structured steps, model calls, latency metrics, and tool logs.

result.steps → [model, tool, handoff]
1Runtime DependencyZod core only
100%Type SafetyStrict TypeScript inference
3Native ProvidersOpenAI, Google & Claude today
5Default Max StepsConfigurable per agent

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.

@chai-ai/openai@chai-ai/google@chai-ai/anthropic

Running in about two minutes.