Integrations
Schema Stream consumes an async sequence of JSON text or UTF-8 bytes. Provider SDKs remain responsible for generation, structured-output validation, retries, cancellation, and the authoritative final result.
Schema Stream consumes an async sequence of JSON text or UTF-8 bytes. Provider SDKs remain responsible for generation, structured-output validation, retries, cancellation, and the authoritative final result.
Choose the guide for the stream surface you already use:
- OpenAI Agents SDK uses
result.toTextStream(). - Vercel AI SDK uses
streamText().textStreamwithOutput.object(). - Mastra explains when to prefer
objectStreamand how the guarded compatibility path works. - Bun WebSocket keeps parsing and credentials on the server and sends complete application messages to the browser.
- Provider portability defines the tested boundary for OpenAI, Anthropic, and Gemini models without claiming untested native adapters.
The executable fixtures are the source of truth. From a repository checkout, run:
bun run examples
bun test tests/sdk-runtime.test.ts
bun run test:packedThose commands are credential-free. Opt-in live tests and their environment contract are described in Integration testing. Schema Stream does not validate intermediate snapshots; validate or await the producing SDK's final structured result before committing data or triggering irreversible work.
schema-stream
Progressively parse streamed JSON into typed, schema-shaped snapshots.
OpenAI Agents SDK
The OpenAI Agents SDK exposes model text as an async stream through toTextStream(). Pass that stream to SchemaStream.iterate() on the server, render the progressive snapshots, then treat the Agents SDK result as authoritative after the run completes.