Skip to content

[Bug] OpenAI Audio handler hardcodes filename without extension, causing "Unrecognized file format" error #838

@pleasantbalogun

Description

@pleasantbalogun

Description

The OpenAI Audio handler hardcodes the filename as 'audio' without a file extension when uploading to the Whisper API. OpenAI uses the filename extension to determine the audio format, so this causes an "Unrecognized file format" error.

Location

https://github.com/prism-php/prism/blob/main/src/Providers/OpenAI/Handlers/Audio.php#L56

->attach(
    'file',
    $request->input()->resource(),
    'audio',  // <-- Missing extension
    ['Content-Type' => $request->input()->mimeType()]
)

Expected Behavior
The filename should include the extension based on MIME type (e.g., audio.webm, audio.mp3), similar to how the Groq handler does it: https://github.com/prism-php/prism/blob/main/src/Providers/Groq/Handlers/Audio.php#L92-L110

Regression
This worked in v0.82 which used `SpeechToTextRequestMapper`. The mapper was removed in v0.99+ and replaced with inline code that hardcodes the filename.

Suggested Fix
Add a `generateFilename()` method (like Groq has) and use it instead of the hardcoded 'audio' string.

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