You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal: Add built-in support for AI streaming queries (partial responses, token-level updates, abort, and resume)
Description:
Modern AI APIs (OpenAI, Anthropic, Google, AWS, Vercel AI SDK, etc.) use streaming responses that deliver output chunk-by-chunk. Many production AI apps need to:
Show partial tokens as they arrive
Update UI continuously during the stream
Support cancel mid-stream
Support resume on the same query key
Cache the final output while ignoring partial chunks
Integrate seamlessly with useQuery/useMutation
TanStack Query works well for REST/JSON, but AI streaming introduces unique challenges:
Problems:
Streaming responses don’t fit naturally into useQuery.
Cached data = final response, but UI = partial tokens → mismatch.
No standardized chunk buffering or reducer pattern.
Abort + resume logic must be custom-implemented.
Partial streams shouldn’t pollute cache.
Mutations are commonly used, but lack structure for streaming UIs.
Proposal:
Introduce a new “streaming query mode” with:
streamQuery API
partial: live tokens
data: final cached response
isStreaming: state
abort: cancel generation
resume: continue generation
appendChunk: controlled chunk merging
Built-in chunk reducer
(chunk, prev) => next
Native AbortController integration
Cache only final output, not partial chunks
Streaming refetch policy
continue?
restart?
reuse generation context?
Example use cases:
AI chat completions
Code generation
Live markdown rendering
Terminal-style token streaming
Why this matters:
Most modern AI apps depend on streaming. Without first-class support, teams must build custom fetchEventSource or ReadableStream handlers. Native streaming query support would make TanStack Query a top-tier choice for AI applications.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal: Add built-in support for AI streaming queries (partial responses, token-level updates, abort, and resume)
Description:
Modern AI APIs (OpenAI, Anthropic, Google, AWS, Vercel AI SDK, etc.) use streaming responses that deliver output chunk-by-chunk. Many production AI apps need to:
TanStack Query works well for REST/JSON, but AI streaming introduces unique challenges:
Problems:
Proposal:
Introduce a new “streaming query mode” with:
Built-in chunk reducer
(chunk, prev) => next
Native AbortController integration
Cache only final output, not partial chunks
Streaming refetch policy
Why this matters:
Most modern AI apps depend on streaming. Without first-class support, teams must build custom fetchEventSource or ReadableStream handlers. Native streaming query support would make TanStack Query a top-tier choice for AI applications.
Beta Was this translation helpful? Give feedback.
All reactions