{
  "id": 13049369,
  "title": "One call, from fetch to a validated object — streaming structured output without the plumbing",
  "url": "https://urgent.news/2026/10/09/one-call-from-fetch-to-a-validated-object-streaming-structured-output",
  "topic": "ai",
  "section": "AI",
  "published": "2026-10-09T06:35:27.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/h1manshu01/one-call-from-fetch-to-a-validated-object-streaming-structured-output-without-the-plumbing-2jko"
  },
  "original_language": "en",
  "account": "You instructed the model to deliver a JSON object, enabling streaming output. You initiated the request using fetch with POST method and provided the body. A reader and decoder were set up to process the response. The loop iterated, appending decoded lines to a buffer and parsing JSON. If the payload matched [DONE], it continued to the next iteration. After each line, the buffer was updated to exclude the processed lines. On successful parsing, the data was set or appended to the JSON string. Once the loop completed, the parsed JSON was converted into a valid object using Schema.parse. The operation entailed tackling three issues - the transport, partial parsing, and validation. I created three separate packages to address these issues, followed by another package that integrated them. With a single call to structured, you obtained both an async iterable of partial snapshots and a holder for the final validated result. The return value is both an async iterable for live partials and a holder for the final validated result.",
  "summary": "You asked the model for a JSON object and set stream: true , because you want the UI (or the next step) to start the moment the first field lands instead of blocking on the last token. Then you're here: const res = await fetch ( url , { method : \" POST \" , body }); const reader = res . body ! . getReader (); const decoder = new TextDecoder (); let buf = \"\" , json = \"\" ; for (;;) { const { value ,…",
  "key_points": [
    "Fetch initiates request with POST method and provided body",
    "Reader and decoder process response, loop appends decoded lines to buffer",
    "Schema.parse converts parsed JSON into a valid object"
  ],
  "editors_take": "This development simplifies accessing structured output by consolidating the process into a single call, eliminating the need for manual handling of transport, partial parsing, and validation.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}