Skip to content

[Workers AI] Undefined result for models that return binary output #2695

@mattrothenberg

Description

@mattrothenberg

Confirm this is a Typescript library issue and not an underlying Cloudflare API issue

  • This is an issue with the Typescript library

Describe the bug

Hello!

I can't tell if I'm holding the SDK wrong, but when I use the Typescript SDK to run a model like leonardo/phoenix-1.0 that, according to the docs, returns the following payload...

{
  "type": "string",
  "contentType": "image/jpeg",
  "format": "binary",
  "description": "The generated image in JPEG format"
}

...I get an undefined output. If I run a model that returns a base64 string (like schnell), I get back a JSON object that correctly reflects the type that's in the documentation.

What could I be doing wrong?

To Reproduce

Run this snippet:

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const output = await client.ai.run("@cf/leonardo/phoenix-1.0", {
  prompt: "A cat eating soup dumplings",
  account_id: process.env['CLOUDFLARE_ACCOUNT_ID']!,
}) 
console.log('Output type:', typeof output);
console.log('Output:', output);

Observe this output:

Output type: undefined
Output: undefined

Code snippets

OS

macOS

Runtime version

Typescript 5.7.3

Library version

v5.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions