TanStack AI's team explains why they refactored their monolithic provider adapters into smaller, single-purpose micro-adapters (e.g. splitting a single openai function into openaiText, openaiImage, openaiSummarize). The change targets bundle splitting, easier development, and a simpler type system, reducing generic type parameters from a projected 20-30 down to a max of 3, and making it easier for external contributors to add new provider support.
Table of contents
The Problem #Bundle Splitting #Ease of Development #Better Type System #What We Explored Instead #Where We Landed #Questions this post answers
Why did TanStack AI split its provider adapters like openai into separate functions such as openaiText and openaiImage?
TanStack AI split its single monolithic provider adapters into smaller, function-specific adapters to solve three problems: bundle splitting, ease of development, and a better type system. The old openai function became openaiText, openaiImage, openaiSummarize, and more, so developers only bundle the functionality they actually use, avoiding unused kilobytes in their app. Track architectural shifts like this one in your AI toolchain by following TanStack AI updates on daily.dev.
How many TypeScript generics did the old TanStack AI BaseAdapter have compared to the new split adapter design?
The old monolithic BaseAdapter had already grown to 7 type generics while only supporting chat, and was projected to reach 20-30 generics once other functionalities like image and summarization were added. After splitting into micro-adapters, the generics max out at 3, making it far easier for external contributors to build new provider adapters. Developers weighing adapter architecture trade-offs can follow these design decisions on daily.dev.