TanStack AI

Build type-safe streaming, tool-calling, and multimodal apps across AI providers.

Source repo
TanStack/ai
Stars
★ 3.2k
Last updated
4d ago
License
MIT
Primary language
TypeScript

At a glance

How it runs
Library / SDKFramework
Works with
Universal · cross-platformOpenAI API · Claude APICodex · Claude Code (Partial support)
Cost
Free software; you pay for model usage
Setup effort
Medium · a few setup steps
You'll need
TypeScriptpnpmSelected provider and framework packagesShell / CLINetwork access
Typical use
A React, Vue, Svelte, Solid, or Preact team adding streaming chat with typed messages and tool calls to an existing application.
Not a fit if
  • Teams wanting a ready-hosted chat product; you build the app, server, and deployment
  • Teams committed to a single vendor model and unwilling to manage adapter packages
Source review
76/100 · Some gaps

What does this agent do, and when should you use it?

TanStack AI is a TypeScript SDK built around composable activities and provider adapters for streaming chat, tool-calling agents, structured output, realtime voice, and media generation. Its core @tanstack/ai package supplies APIs such as chat() and toolDefinition(), while separate adapters connect OpenAI, Anthropic, Gemini, Ollama, Grok, Groq, ElevenLabs, BytePlus, fal.ai, and OpenRouter. The client layer includes the headless @tanstack/ai-client package and native bindings for React, Solid, Vue, Svelte, and Preact. It handles text, images, audio, video, and documents, with structured results backed by JSON Schema, Zod, ArkType, or Valibot. The library runs inside the adopter's frontend or server application rather than as a hosted product; model access, credentials, hosting, and costs remain tied to the selected adapters. It is a fit for TypeScript teams that value provider portability and typed contracts and are prepared to own application integration and deployment.

An application passes messages to chat() and selects a model through an activity adapter such as openaiText(); toServerSentEventsResponse() can expose the resulting stream as a server-sent events response. toolDefinition() declares a shared input and output schema, then attaches a server or client implementation with .server() or its client counterpart. Supplying outputSchema makes a chat call produce an object constrained through JSON Schema, Zod, ArkType, Valibot, or plain JSON Schema. Generation clients use a shared pattern to call image, audio, video, speech, transcription, and summarization services, while realtime adapters handle voice sessions and token minting. Code Mode lets a model write and execute TypeScript in an isolated sandbox to orchestrate tools with loops, branches, and parallel calls. Devtools, typed observability events, usage and error reporting, and OpenTelemetry traces expose messages, tool calls, and stream chunks for inspection.

  1. A React, Vue, Svelte, Solid, or Preact team adding streaming chat with typed messages and tool calls to an existing application.
  2. A TypeScript backend team that wants server and client tools to share one toolDefinition() input and output contract.
  3. A product team that expects to switch among OpenAI, Anthropic, Gemini, Ollama, or another documented adapter.
  4. A developer who needs model responses validated as Zod, ArkType, Valibot, or JSON Schema objects instead of free-form prose.
  5. A multimodal application combining image, video, speech, transcription, audio, or summarization workflows under one generation-client pattern.
  6. An advanced AI application that needs realtime voice, Code Mode orchestration, devtools, or OpenTelemetry observability.

How do you install or deploy this agent?

Install the core package and OpenAI adapter:

pnpm add @tanstack/ai @tanstack/ai-openai

For React streaming chat, also install the client and React packages:

pnpm add @tanstack/ai @tanstack/ai-client @tanstack/ai-react @tanstack/ai-openai

To reach multiple models through one API entry point, install the OpenRouter adapter:

pnpm add @tanstack/ai @tanstack/ai-openrouter

The supplied material does not state a Node.js version or document provider credential variable names and setup. Those access details must be supplied for the selected adapter before it can make provider calls.

How do you use this agent?

Create a chat stream in a TypeScript server route that supports standard Request, Response, and server-sent events:

import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'

export async function POST(request: Request) {
  const body = await request.json()

  const stream = chat({
    adapter: openaiText('gpt-5.2'),
    messages: body.messages,
  })

  return toServerSentEventsResponse(stream)
}

The caller sends a JSON request containing messages to this POST endpoint. This example selects the OpenAI adapter and gpt-5.2; the supplied material does not show credential configuration, error handling, or a deployment command.

For typed structured data, add an outputSchema:

import { chat } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'
import { z } from 'zod'

const Person = z.object({
  name: z.string(),
  age: z.number(),
})

const person = await chat({
  adapter: openaiText('gpt-5.2'),
  messages: [{ role: 'user', content: 'Ada Lovelace, 36' }],
  outputSchema: Person,
})

What are this agent's strengths and limitations?

Pros
  • Official adapters cover OpenAI, Anthropic, Gemini, Ollama, OpenRouter, Grok, Groq, ElevenLabs, BytePlus, and fal.ai, reducing dependence on one provider.
  • toolDefinition() gives server and client implementations a shared, typed input and output contract.
  • One SDK spans streaming chat, structured output, realtime voice, image, audio, video, speech, transcription, and summarization workflows.
  • It includes React, Solid, Vue, Svelte, Preact, and headless clients, with activity-level tree-shaking.
  • Typed observability events, devtools, and OpenTelemetry support expose streams, tool calls, errors, and usage for inspection.
Limitations
  • Adopters must choose, install, and configure provider and framework packages; the supplied material does not provide a complete credential setup.
  • Capability coverage differs by adapter: some focus on chat, while only certain adapters expose image, video, speech, or realtime features.
  • Teams must maintain a TypeScript application, server endpoints, and deployment environment because this is not a ready-hosted chat product.
  • Code Mode executes model-written TypeScript in an isolated sandbox, but the supplied material does not specify its security policy, permission boundary, or deployment requirements.
  • No supported Node.js version, retry strategy, rate-limit handling, or production recovery configuration is documented in the supplied material.

How does this agent compare with similar options?

The project links to a “TanStack AI vs Vercel AI SDK” guide covering architecture, feature coverage, and tradeoffs. The supplied material does not include that guide's findings, so it does not support claims that either option is better on performance, cost, or functionality.

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
TanStack AI This agent 76 · Some gaps Library / SDKFree + model costs ★ 3.2k 4d ago TypeScript OpenAI API · Claude API
Mirascope 55 · Major gaps Library / SDKFree + model costs ★ 1.5k 1d ago Python Claude API
Rig 70 · Some gaps Library / SDKFree + model costs ★ 8.9k today Rust OpenAI API
Adaline Gateway 69 · Some gaps Library / SDKFree + model costs ★ 607 2mo ago TypeScript OpenAI API · Claude API

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Some gaps
Why not a higher tier: Trust & safety is 16/29, below the 18/29 needed for “Good”; the tier is lowered because risk is not averaged away.
76/ 100 5-point scale 3.8 / 5
This review covers the source as of Aug 16, 2026. The project has shipped 20 stable release(s) since, which have not been re-reviewed. The score and verdict describe the reviewed version only. Recent releases ↓
Trust 16/29
Reliability 12/14
Adaptability 15/18
Convention 14/18
Effectiveness 12/13
Verifiability 7/8
Why each dimension lost points
Trust16 / 29 · 2.8/5

Workflows use read-only contents permission, disable persisted credentials, and pin third-party Actions by commit; Code Mode is described as isolated, and the ACP tests exercise sandbox boundaries. Deductions apply because the SDK can invoke external models, tools, local processes, and media services while the supplied files do not fully specify runtime least privilege, network scope, or default tool authorization; approval is represented only by a documentation link. Provider and observability flows are reasonably visible, but API-key handling, log redaction, prompt retention, and sensitive-data policy are absent. ACP safely refuses an unrecoverable attach and explains rerun and double-append risks, but no general framework-wide rollback mechanism is shown. Repository, package, MIT copyright holder, and community paths provide attribution; the unverified publisher is treated as unknown, not as adverse evidence, but the files do not establish a fully accountable organizational identity.

Reliability12 / 14 · 4.3/5

The README, package scripts, workflows, and ACP tests align closely on streaming events, session behavior, protocol negotiation, run IDs, and durability constraints, justifying full self-consistency credit. Multiple providers and a local Ollama option reduce single-provider dependence, but operation still relies on npm packages, runtimes, model vendors, and external services, with no complete offline-degradation account. Failure-message evidence is strong: configuration errors, protocol mismatches, and unsupported attaches produce specific, actionable messages that distinguish non-transient failure from retryable conditions.

Adaptability15 / 18 · 4.2/5

The material explicitly covers React, Vue, Svelte, Solid, Preact, headless, server-only, realtime, multimodal, and multi-provider scenarios, thoroughly addressing audiences and environments. Boundaries are partly explicit—notably the ACP adapter's lack of journaling and the Bun-specific driver requirement—but important limitations appear mainly in test commentary rather than top-level guidance. Typed tool schemas, client/server implementations, and a referenced approval flow support reasonably precise triggering, but the approval documentation and enforcement policy are not included.

Convention14 / 18 · 3.9/5

The README has clear start paths, capability groupings, provider and framework tables, and advanced-documentation navigation. Installation commands are useful, but in-place guidance for credentials, runtime versions, and production deployment is incomplete. Package naming is consistent and changesets/release machinery exists, though no compatibility promise is supplied for the expanding adapter surface. Examples cover chat, tools, and structured output, but no FAQ is included. Limitations are evidenced in tests but lack a consolidated limitations section. The full MIT license earns full credit. Contribution, community, and maintenance automation paths exist, but named responsibility, response commitments, and a security-update route are not established.

Effectiveness12 / 13 · 4.6/5

Streaming events, typed tools, structured outputs, multimodal activities, and framework bindings produce directly consumable application results, supporting full output-usability credit. A unified provider/activity abstraction, runtime switching, Code Mode, and observability offer substantial marginal value over a minimal model client. Tree-shaking, optional packages, and OpenRouter cost tracking help control expense, but no quantitative performance, pricing, latency, or operational-burden evidence supports full cost-benefit credit.

Verifiability7 / 8 · 4.4/5

Core claims trace to concrete README examples, package scripts, commit-pinned workflows, and detailed ACP behavior tests. These independent file types corroborate validation, protocol negotiation, sandbox execution, event output, and durability limitations, supporting strong traceability and cross-source corroboration. Deductions apply because several broad capability, isolation-security, and award claims remain summaries or external-link assertions without corresponding implementation or independent evidence in the supplied material; test source demonstrates intended coverage, not that tests passed at this revision.

Risks and how to mitigate them
  • The ACP-compatible adapter does not currently journal; durable attach is refused, and a fresh durable run is explicitly not recoverable later.
  • Code Mode and local-process adapters can execute generated code or commands; deployers should independently constrain filesystem, network, credential, and tool permissions and define explicit approval boundaries.
  • The supplied material does not document API-key protection, prompt or media retention, log redaction, or provider data policies; review these before processing sensitive data.
  • This assessment is based only on the supplied static files. Tests were not run, and external documentation, awards, published artifacts, and dependency-vulnerability status were not independently verified.
Evidence confidence: Low Reviewed Aug 16, 2026 Reviewed revision 0fb826321c9b New commits since this review; the score may not cover them
See the full review method →

Recent releases

Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.

  1. Release notes excerpt
    Minor Changes - [#1715](https://github.com/TanStack/ai/pull/1715) [fac0555](https://github.com/TanStack/ai/commit/fac055559de98eb0fa23a0bc725808033ba3c2fc) - New hooks for hosts that run chat() for a long session. - @tanstack/ai exports runAgentStream (runs a defineAgent agent outside a parent chat turn), createSubagentId, createSubagentSink, CapabilityRegistry, and the SubagentsBag and SubagentSink types. Pass the sink to keep interrupt objects and token usage. The finished event has interruptIds only. …
    View on GitHub ↗
  2. Release notes excerpt
    Patch Changes - Updated dependencies \[[1bfcee3](https://github.com/TanStack/ai/commit/1bfcee35bb3cf0ff3aac005440c842e66c3d687d), [412b0fe](https://github.com/TanStack/ai/commit/412b0fea4f4bb569998c3d253d174efd7b501e3c), [a0150c2](https://github.com/TanStack/ai/commit/a0150c26b9e2b6050663450171e36a9dfa80915b), [b881627](https://github.com/TanStack/ai/commit/b881627d51076dcc1af031ac951046e2fb7d84c4), [fac0555](https://github.com/TanStack/ai/commit/fac055559de98eb0fa23a0bc725808033ba3c2fc), [6774e80](https://github.com/TanStack/ai/commit/6774e803da3205101613ab2857c9ed4fbf97568 …
    View on GitHub ↗
  3. Release notes excerpt
    Patch Changes - Updated dependencies \[[1bfcee3](https://github.com/TanStack/ai/commit/1bfcee35bb3cf0ff3aac005440c842e66c3d687d), [412b0fe](https://github.com/TanStack/ai/commit/412b0fea4f4bb569998c3d253d174efd7b501e3c), [a0150c2](https://github.com/TanStack/ai/commit/a0150c26b9e2b6050663450171e36a9dfa80915b), [b881627](https://github.com/TanStack/ai/commit/b881627d51076dcc1af031ac951046e2fb7d84c4), [fac0555](https://github.com/TanStack/ai/commit/fac055559de98eb0fa23a0bc725808033ba3c2fc), [6774e80](https://github.com/TanStack/ai/commit/6774e803da3205101613ab2857c9ed4fbf97568 …
    View on GitHub ↗

FAQ

Do I have to use OpenAI?
No. Documented adapters include Anthropic, Gemini, Ollama, OpenRouter, Grok, Groq, ElevenLabs, BytePlus, and fal.ai, and the SDK supports runtime adapter switching.
Does the package include hosting or model usage?
It is described as an SDK, not a hosted service. Model access, deployment, and charges depend on the chosen provider; only the OpenRouter entry explicitly mentions per-request cost tracking.
Can tools run in the browser?
toolDefinition() can attach server or client implementations to the same contract. The material does not prescribe where sensitive operations or permissions should be placed.
Can it run without a frontend framework?
Yes. A Server Only quick start is listed for endpoints, scripts, and backend services, and @tanstack/ai-client provides a headless client.
Does it integrate with Codex and Claude Code?
The Agent Skills documentation explicitly says TanStack AI skills can be installed into Codex, Claude Code, and other coding agents. The supplied material does not show that these integrations expose every SDK capability, so compatibility is assessed as partial.
View on GitHub ↗ Install ↓

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related agents