Skip to content

blog: stream structured output end-to-end with useChat({outputSchema})#923

Merged
KevinVandy merged 2 commits into
TanStack:mainfrom
AlemTuzlak:blog/streaming-structured-output
May 14, 2026
Merged

blog: stream structured output end-to-end with useChat({outputSchema})#923
KevinVandy merged 2 commits into
TanStack:mainfrom
AlemTuzlak:blog/streaming-structured-output

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

Announces the TanStack AI release that folds streaming structured output into useChat: pass a Zod schema, get a typed partial and final back. Companion blog post for TanStack/ai#527.

What's in the post

  • The old shape: 15 lines of onChunk + useState + parsePartialJSON + a manual cast.
  • The new shape: const { partial, final } = useChat({ outputSchema: PersonSchema }).
  • The type-system changes that made it possible: StructuredOutputStream<T> with proper discriminated narrowing, tagged ApprovalRequestedEvent and ToolInputAvailableEvent variants.
  • Provider coverage: OpenAI, OpenRouter, Grok, Groq, Ollama, plus the summarize adapter.
  • Framework parity across React, Vue, Solid, and Svelte.
  • End-to-end "Try it" with the schema, the server route, and the client hook.

Files

  • src/blog/streaming-structured-output.md — the post (~960 words).
  • public/blog-assets/streaming-structured-output/header.png — cover image.

Verified

  • oxfmt (pre-commit) ran clean on the post.
  • tsc + oxlint (pre-commit) found no new issues. The lint warnings printed in the hook are pre-existing in unrelated files.

AlemTuzlak and others added 2 commits May 14, 2026 21:02
Announces the TanStack AI release that folds streaming structured output into
useChat: pass a Zod schema, get a typed `partial` and `final` back. Covers
the old glue (manual parsePartialJSON + onChunk + casts), the new hook shape,
the type-system changes (StructuredOutputStream<T> + tagged variants for
ApprovalRequestedEvent / ToolInputAvailableEvent), provider coverage
(OpenAI / OpenRouter / Grok / Groq / Ollama), and framework parity across
React / Vue / Solid / Svelte.
@KevinVandy KevinVandy merged commit 8b761f5 into TanStack:main May 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants