|
| 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"> |
| 32 | + |
| 33 | +### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/) |
| 34 | +</div> |
| 35 | + |
| 36 | +# TanStack AI |
| 37 | + |
| 38 | +A 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 | + |
| 49 | +### <a href="https://tanstack.com/ai">Read the docs →</b></a> |
| 50 | + |
| 51 | +## Tree-Shakeable Adapters |
| 52 | + |
| 53 | +Import only the functionality you need for smaller bundle sizes: |
| 54 | + |
| 55 | +```typescript |
| 56 | +// Only chat functionality - no summarization code bundled |
| 57 | +import { openaiText } from '@tanstack/ai-openai/adapters' |
| 58 | +import { generate } from '@tanstack/ai' |
| 59 | + |
| 60 | +const textAdapter = openaiText() |
| 61 | + |
| 62 | +const result = generate({ |
| 63 | + adapter: textAdapter, |
| 64 | + model: 'gpt-4o', |
| 65 | + messages: [{ role: 'user', content: [{ type: 'text', content: 'Hello!' }] }], |
| 66 | +}) |
| 67 | + |
| 68 | +for await (const chunk of result) { |
| 69 | + console.log(chunk) |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +Available adapters: `openaiText`, `openaiEmbed`, `openaiSummarize`, `anthropicText`, `geminiText`, `ollamaText`, and more. |
| 74 | + |
| 75 | +## Get Involved |
| 76 | + |
| 77 | +- We welcome issues and pull requests! |
| 78 | +- Participate in [GitHub discussions](https://github.com/TanStack/ai/discussions) |
| 79 | +- Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ) |
| 80 | +- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions |
| 81 | + |
| 82 | +## Partners |
| 83 | + |
| 84 | +<table align="center"> |
| 85 | + <tr> |
| 86 | + <td> |
| 87 | + <a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" > |
| 88 | + <picture> |
| 89 | + <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-CMcuvjEy.svg" height="40" /> |
| 90 | + <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" /> |
| 91 | + <img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" /> |
| 92 | + </picture> |
| 93 | + </a> |
| 94 | + </td> |
| 95 | + <td> |
| 96 | + <a href="https://www.cloudflare.com?utm_source=tanstack"> |
| 97 | + <picture> |
| 98 | + <source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-DQDB7UaL.svg" height="60" /> |
| 99 | + <source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" /> |
| 100 | + <img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" /> |
| 101 | + </picture> |
| 102 | + </a> |
| 103 | + </td> |
| 104 | + </tr> |
| 105 | +</table> |
| 106 | + |
| 107 | +<div align="center"> |
| 108 | +<img src="./media/partner_logo.svg" alt="AI & you?" height="65"> |
| 109 | +<p> |
| 110 | +We'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. |
| 111 | +</p> |
| 112 | +<a href="mailto:partners@tanstack.com?subject=TanStack AI Partnership"><b>LET'S CHAT</b></a> |
| 113 | +</div> |
| 114 | + |
| 115 | +## Explore the TanStack Ecosystem |
| 116 | + |
| 117 | +- <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages |
| 118 | +- <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store |
| 119 | +- <a href="https://github.com/tanstack/devtools"><b>TanStack Devtools</b></a> – Unified devtools panel |
| 120 | +- <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state |
| 121 | +- <a href="https://github.com/tanstack/pacer"><b>TanStack Pacer</b></a> – Debouncing, throttling, batching |
| 122 | +- <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching |
| 123 | +- <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives |
| 124 | +- <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state |
| 125 | +- <a href="https://github.com/tanstack/router"><b>TanStack Start</b></a> – Full‑stack SSR & streaming |
| 126 | +- <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store |
| 127 | +- <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids |
| 128 | +- <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering |
| 129 | + |
| 130 | +… and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a> |
| 131 | + |
| 132 | +<!-- USE THE FORCE LUKE --> |
0 commit comments