Skip to content

Conversation

@notreux
Copy link

@notreux notreux commented Nov 27, 2025

Description

This PR addresses an issue where image generation would fail if the Workers AI binding returned anything other than a ReadableStream.

Changes:

  • Refactored WorkersAIImageModel.doGenerate to handle polymorphic return types from the binding.
  • Introduced a toUint8Array helper function that safely converts the following inputs into Uint8Array:
    • ReadableStream (existing behavior)
    • Uint8Array / ArrayBuffer
    • JSON response with Base64 ({ image: string }).
  • Added unit tests for image generation (previously missing) to verify these scenarios.

Related Issue

Fixes #272

Refactored response handling to support non-stream outputs and added missing unit test.
@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2025

🦋 Changeset detected

Latest commit: 97b79e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
workers-ai-provider Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 4, 2025

Open in StackBlitz

npx https://pkg.pr.new/cloudflare/ai/ai-gateway-provider@311
npx https://pkg.pr.new/cloudflare/ai/workers-ai-provider@311

commit: 97b79e2

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.

Error generating images with workers-ai-provider

1 participant