Skip to content

fix(aisdk): request non-streaming response in doGenerate (#470)#515

Open
serhiizghama wants to merge 2 commits into
ax-llm:mainfrom
serhiizghama:fix/aisdk-dogenerate-non-streaming
Open

fix(aisdk): request non-streaming response in doGenerate (#470)#515
serhiizghama wants to merge 2 commits into
ax-llm:mainfrom
serhiizghama:fix/aisdk-dogenerate-non-streaming

Conversation

@serhiizghama
Copy link
Copy Markdown
Contributor

Problem

When using the @ax-llm/ax-ai-sdk-provider with generateText (or any non-streaming Vercel AI SDK entrypoint), the call crashes with:

TypeError: Cannot read properties of undefined (reading 'at')
    at AxAIProvider.doGenerate (provider.ts:153:32)

AxAIProvider.doGenerate was calling this.ai.chat(req) without the second options argument. AxBaseAI.chat defaults stream to true when no value is supplied, so the call returned a ReadableStream<AxChatResponse> cast as AxChatResponse. Accessing res.results.at(0) on the stream therefore threw — see the original report in #470.

Solution

Explicitly pass { stream: false } from doGenerate so the underlying service always returns a single AxChatResponse, matching the cast already used a line below. doStream continues to pass { stream: true } and is unchanged.

Testing

  • npx vitest run src/aisdk/index.test.ts — 8/8 pass.
  • New test asserts that doGenerate forwards stream: false to ai.chat.
  • Existing prompt conversion test updated to expect the new second argument.

Closes #470.

The Vercel AI SDK provider was calling ai.chat(req) without options,
relying on the default behavior. AxBaseAI defaults stream to true when
omitted, causing chat() to return a ReadableStream cast as
AxChatResponse, so accessing res.results.at(0) threw
"Cannot read properties of undefined (reading 'at')" when used through
generateText/streamText with non-streaming entrypoints.

Pass { stream: false } explicitly so doGenerate always receives an
AxChatResponse and the existing cast holds.
Add an assertion that doGenerate forwards stream: false to ai.chat, and
update the existing prompt-conversion test to match the new second
argument.
@falmanna
Copy link
Copy Markdown

does this make the integration work with V6 as well?

@dosco
Copy link
Copy Markdown
Collaborator

dosco commented May 13, 2026

can you fix the merge conflict so i can merge this

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.

Vercel integration examples don't appear to be correct

3 participants