This repository was archived by the owner on Jun 3, 2026. It is now read-only.
Repository navigation
v0.131.0
Added
-
ObjectStreamResponseandObjectStreamFromResponseserialization functions for using server-generated object streams in web applications.Server example:
export async function POST(req: Request) { const { myArgs } = await req.json(); const objectStream = await streamObject({ // ... }); // serialize the object stream to a response: return new ObjectStreamResponse(objectStream); }
Client example:
const response = await fetch("/api/stream-object-openai", { method: "POST", body: JSON.stringify({ myArgs }), }); // deserialize (result object is simpler than the full response) const stream = ObjectStreamFromResponse({ schema: itinerarySchema, response, }); for await (const { partialObject } of stream) { // do something, e.g. setting a React state }
Changed
-
breaking change: rename
generateStructuretogenerateObjectandstreamStructuretostreamObject. Related names have been changed accordingly. -
breaking change: the
streamObjectresult stream contains additional data. You need to usestream.partialObjector destructuring to access it:const objectStream = await streamObject({ // ... }); for await (const { partialObject } of objectStream) { console.clear(); console.log(partialObject); }
-
breaking change: the result from successful
Schemavalidations is stored in thevalueproperty (before:data).