cloudflare / cloudflare/workerd

`AiTextToImageOutput` should be a ReadableStream instead of `Uint8Array`

Open
#2,470 0 comments 0 reactions 1 assignee Claimed by @workers-devprod View on GitHub
types
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

Hello,

I am using `env.AI.run('@cf/stabilityai/stable-diffusion-xl-base-1.0', input)` to generate image. The return type of this function is `AiTextToImageOutput` which is a type alias of Uint8Array. Yet, `env.AI.run()` seems to return a `ReadableStream` instead of `Uint8Array`

## Minimal reproducible example
```javascript
const result = await env.AI.run(
"@cf/stabilityai/stable-diffusion-xl-base-1.0",
{
prompt:
"An artistic cartoon of a cat playing with a new technology gadget in a sunny computer lab, surrounded by colorful flowers and Server guarantees serene background",
num_steps: 20,
guidance: 7,
}
);
// logs:
// ReadableStream {
// locked: false,
// [state]: 'readable',
// [supportsBYOB]: true,
// [length]: undefined
// }
console.log(result);
```

## Tested with
wrangler version: 3.67.1
@cloudflare/workers-types version: 4.20240725.0
node version: 22.5.0

I am happy to submit a PR if this a bug

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.