feat: add includeRawChunks support for streaming#360
Merged
robert-j-y merged 2 commits intomainfrom Jan 27, 2026
Merged
Conversation
When includeRawChunks: true is passed to streaming calls, the provider
now emits { type: 'raw', rawValue: <parsed chunk> } stream parts for
each SSE event, giving consumers access to the raw provider chunks
alongside the processed AI SDK stream parts.
This feature is available for both chat and completion models.
Closes #340
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
Documents the intentional behavior that raw chunks are emitted before validation, which is useful for debugging malformed responses. This matches the Vercel AI SDK reference implementation pattern. Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
Merged
kesavan-byte
pushed a commit
to osm-API/ai-sdk-provider
that referenced
this pull request
Feb 13, 2026
* feat: add includeRawChunks support for streaming
When includeRawChunks: true is passed to streaming calls, the provider
now emits { type: 'raw', rawValue: <parsed chunk> } stream parts for
each SSE event, giving consumers access to the raw provider chunks
alongside the processed AI SDK stream parts.
This feature is available for both chat and completion models.
Closes OpenRouterTeam#340
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* test: add test for raw chunk emission on failed parse
Documents the intentional behavior that raw chunks are emitted before
validation, which is useful for debugging malformed responses. This
matches the Vercel AI SDK reference implementation pattern.
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements
includeRawChunkssupport for streaming calls in both chat and completion models. WhenincludeRawChunks: trueis passed todoStream(), the provider emits{ type: 'raw', rawValue: <parsed chunk> }stream parts for each SSE event, giving consumers access to the raw provider chunks alongside the processed AI SDK stream parts.This follows the same implementation pattern used in the Vercel AI SDK's
@ai-sdk/openai-compatibleprovider - raw chunks are emitted at the start of the transform function, before any other processing.Before:
After:
Closes #340
Updates since last revision
Added test coverage for failed parse scenarios to document the intentional behavior: raw chunks are emitted before validation, which is useful for debugging malformed responses. When parsing fails, consumers receive both the raw chunk (containing the unparseable data) and the error chunk.
Human Review Checklist
@ai-sdk/openai-compatiblereference implementationchunk.rawValuefromParseResultcontains the expected parsed JSON — Confirmed:rawValueis always available onParseResult(both success and failure cases)Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset fileLink to Devin run: https://app.devin.ai/sessions/f147987c7c8344f8a0f287947c44a709
Requested by: Robert Yeakel (@robert-j-y)