Skip to content

Downloading image URL parts is based on the initial model but doesn't change if the model gets changed in prepareStep #9091

@williamprofit

Description

@williamprofit

Description

Description

The SDK downloads images when using Image URL parts with providers that don't support them (such as Gemini).

However, there is an issue when deciding whether to download the images or now. This seems to be based off of the model given to streamText / generateText, but it doesn't get updated if the model gets changed dynamically in prepareStep.

This means that if I have

streamText({
  model: openaiProvider("gpt-5"),
  prepareStep: async (step) => {
    return {
      model: geminiProvider("gemini-2.5-flash")
    }
  }
})

It will NOT download the images and send image URLs to gemini.
Vice versa, if I set gemini in model and gpt in prepareStep, it will send base64 images to gpt instead of sending URLs.

AI SDK Version

ai: 5.0.59

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions