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

Abierto
#2,695 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
typescript
Área
ai, api

Línea de trabajo

Start at the client.ai.run entry point shown in the reproduction and trace how responses are handled for the binary-output model versus the base64-string model. Run the provided snippet against leonardo/phoenix-1.0 and confirm that the binary result is returned instead of undefined; add coverage for this behavior if the surrounding code has tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

kind: bug
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

Lenguaje dominante
TypeScript
Estrellas
835
Forks
201
Merge medio
41 min
PR fusionados (30 d)
1

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cloudflare/cloudflare-typescript

Todos los issues de cloudflare/cloudflare-typescript

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.