Open History to see the last commit
1<div align="center">
2 <img src="./media/header_ai.png" >
3</div>
4
5<br />
6
7<div align="center">
8<a href="https://npmjs.com/package/@tanstack/ai" target="\_parent">
9 <img alt="" src="https://img.shields.io/npm/dm/@tanstack/ai.svg" />
10</a>
11<a href="https://github.com/TanStack/ai" target="\_parent">
12 <img alt="" src="https://img.shields.io/github/stars/TanStack/ai.svg?style=social&label=Star" alt="GitHub stars" />
13</a>
14<a href="https://bundlephobia.com/result?p=@tanstack/ai@latest" target="\_parent">
15 <img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/ai@latest" />
16</a>
17</div>
18
19<div align="center">
20<a href="#badge">
21 <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
22</a>
23 <a href="#badge">
24 <img src="https://img.shields.io/github/v/release/tanstack/ai" alt="Release"/>
25 </a>
26<a href="https://twitter.com/tan_stack">
27 <img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/>
28</a>
29</div>
30
31<div align="center">
33### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
34</div>
35
36# TanStack AI
37
38A powerful, type-safe AI SDK for building AI-powered applications.
39
40- Provider-agnostic adapters (OpenAI, Anthropic, Gemini, Ollama, etc.)
41- **Tree-shakeable adapters** - Import only what you need for smaller bundles
42- **Multimodal content support** - Send images, audio, video, and documents
43- **Image generation** - Generate images with OpenAI DALL-E/GPT-Image and Gemini Imagen
44- Chat completion, streaming, and agent loop strategies
45- Headless chat state management with adapters (SSE, HTTP stream, custom)
46- Isomorphic type-safe tools with server/client execution
47- **Enhanced integration with TanStack Start** - Share implementations between AI tools and server functions
48- **Observability events** - Structured, typed events for text, tools, image, speech, transcription, and video ([docs](./docs/guides/observability.md))
49
50### <a href="https://tanstack.com/ai">Read the docs →</a>
51
52## Tree-Shakeable Adapters
53
54Import only the functionality you need for smaller bundle sizes:
55
56```typescript
57// Only chat functionality - no summarization code bundled
58import { openaiText } from '@tanstack/ai-openai/adapters'
59import { generate } from '@tanstack/ai'
60
61const textAdapter = openaiText()
62
63const result = generate({
64 adapter: textAdapter,
65 model: 'gpt-4o',
66 messages: [{ role: 'user', content: [{ type: 'text', content: 'Hello!' }] }],
67})
68
69for await (const chunk of result) {
70 console.log(chunk)
71}
72```
73
74Available adapters: `openaiText`, `openaiEmbed`, `openaiSummarize`, `anthropicText`, `geminiText`, `ollamaText`, and more.
75
76## Get Involved
77
78- We welcome issues and pull requests!
79- Participate in [GitHub discussions](https://github.com/TanStack/ai/discussions)
80- Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
81- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
82
83## Partners
84
85<table align="center">
86 <tr>
87 <td>
88 <a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" >
89 <picture>
90 <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-D643Zkrv.svg" />
91 <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" />
92 <img src="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" height="40" alt="CodeRabbit" />
93 </picture>
94 </a>
95 </td>
96 <td>
97 <a href="https://www.cloudflare.com?utm_source=tanstack">
98 <picture>
99 <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" />
100 <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-6Ojsn8yh.svg" />
101 <img src="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" height="60" alt="Cloudflare" />
102 </picture>
103 </a>
104 </td>
105 </tr>
106</table>
107
108<div align="center">
109<img src="./media/partner_logo.svg" alt="AI & you?" height="65">
110<p>
111We're looking for TanStack AI Partners to join our mission! Partner with us to push the boundaries of TanStack AI and build amazing things together.
112</p>
113<a href="mailto:partners@tanstack.com?subject=TanStack AI Partnership"><b>LET'S CHAT</b></a>
114</div>
115
116## Explore the TanStack Ecosystem
117
118- <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
119- <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
120- <a href="https://github.com/tanstack/devtools"><b>TanStack Devtools</b></a> – Unified devtools panel
121- <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
122- <a href="https://github.com/tanstack/pacer"><b>TanStack Pacer</b></a> – Debouncing, throttling, batching
123- <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
124- <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
125- <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
126- <a href="https://github.com/tanstack/router"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
127- <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
128- <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids
129- <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
130
131… and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
132
133<!-- USE THE FORCE LUKE -->