Skip to content

streamText breaks when switching from openai to google provider #110

@dancer

Description

@dancer

I switched my app from openai to google provider and now streamText throws errors. The same code works fine with openai.

import { google } from "@ai-sdk/google"
import { streamText } from "ai"

const result = streamText({
  model: google("gemini-2.5-flash"),
  prompt: "tell me a story",
})

for await (const chunk of result.textStream) {
  process.stdout.write(chunk)
}

Throws: TypeError: Cannot read properties of undefined (reading 'choices')

This seems like a compatibility issue between providers. Using ai@6.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions