Skip to content

cf ai run prints {} for models that return binary output (text-to-speech audio) #437

Open

Description

@ferdousbhai

What happens

cf ai run with a text-to-speech model prints {} and exits 0. The audio the model returned is dropped, so there's no way to get it from the CLI.

$ cf ai run @cf/deepgram/aura-2-en --text "Hello there." --encoding mp3 > out.mp3; echo "exit $?"
exit 0
$ xxd out.mp3
00000000: 7b7d 0a                                  {}.

The same request sent straight to the REST API (POST /accounts/{account_id}/ai/run/@cf/deepgram/aura-2-en with {"text": "...", "speaker": "athena", "encoding": "mp3"}) returns 200 with content-type: audio/mpeg and the MP3 bytes. So it looks like the CLI JSON-parses or serializes every response, and a binary body turns into {}.

Expected

When the response isn't JSON (audio/*, image/*, application/octet-stream), write the raw bytes to stdout (or to a file given with --output FILE), and refuse with a clear message when stdout is a terminal. Failing that, at least exit non-zero rather than print {} with success.

This affects @cf/deepgram/aura-1, @cf/deepgram/aura-2-en, @cf/deepgram/aura-2-es and likely the image-generation models too.

Environment

cf 1.0.0-beta.20, Node v26.12.1, Linux aarch64, signed in with cf auth login (OAuth).

Activity

  1. petebacondarwin commented on Oct 28, 2026

    @petebacondarwin
    Collaborator

    We haven't been able to reproduce the dropped binary output in the current 1.0.0-beta.24 code. The hand-written cf ai run command already preserves non-JSON responses as bytes. We expanded its regression tests to cover audio/mpeg, audio/wav, image/png, and application/octet-stream; all write the exact bytes to stdout without JSON serialization.

    These checks use mocked API responses, so they don't yet reproduce the live Deepgram request or the reported Linux/OAuth environment. Also, cf currently calls POST /accounts/{account_id}/ai/run with { model, input }, whereas the successful direct REST example in this issue uses /ai/run/{model_name}. That difference remains worth investigating if the problem persists.

    We found a related generator gap and opened #439: generated commands did not recognize audio/* as binary output. cf ai run is hand-written, so that fix does not explain this particular report.

    Could you retry with the latest 1.0.0-beta.24, confirm the version shown by cf --version, and let us know whether the same command still produces {}? It may no longer reproduce on the latest beta, but we couldn't identify a fix between beta.20 and beta.24: the relevant byte-preserving response code is unchanged between those releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions