POST/audio-to-text

Convert Audio to Text

Available for: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps.

Transcribes an uploaded audio file to text using the workspace's default speech-to-text model.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields
filestringrequired
Audio file to transcribe. Accepted MIME types: `audio/mp3`, `audio/m4a` (also accepted as `audio/x-m4a`), `audio/wav`, `audio/amr`, `audio/mpga`. Other types, including the common `audio/mpeg`, are rejected with `unsupported_audio_type`. Maximum size `30 MB`.
userstringoptional
End-user identifier, defined by your app and unique within it. See [End User Identity](/en/api-reference/guides/end-user-identity).

5 status codes
200Successfully converted audio to text.
textstringoptional
Output text from speech recognition.
400- `no_audio_uploaded` : No audio file was provided in the `file` field. - `speech_to_text_disabled` : Speech-to-text isn't enabled in the app's published configuration. Calling a Chatflow or Workflow app that hasn't been published yet returns this code too. - `provider_not_initialize` : The workspace has no default speech-to-text model, or the default one has no credentials configured. - `invalid_param` : The default speech-to-text model is disabled in the model provider settings, or the model provider it belongs to is no longer installed. - `model_currently_not_support` : On Dify Cloud, the workspace has used up its paid AI credits, and the trial credits it falls back to don't cover its default speech-to-text model. - `completion_request_error` : The model provider rejected the transcription request or failed to complete it, for example because of invalid credentials.

6 documented failures

  • completion_request_error

    [OpenAI] Incorrect model credentials provided, please check and try again.

    completion_request_error

  • invalid_param

    Model whisper-1 is disabled.

    invalid_param

  • model_currently_not_support

    Dify Hosted OpenAI trial currently not support the GPT-4 model.

    model_currently_not_support

  • no_audio_uploaded

    Please upload your audio.

    no_audio_uploaded

  • provider_not_initialize

    Default model not found for speech2text

    provider_not_initialize

  • speech_to_text_disabled

    Speech to text is disabled.

    speech_to_text_disabled

413`audio_too_large` : The audio file exceeds the `30 MB` size limit.

One documented failure

  • audio_too_large

    Audio size larger than 30 mb

    audio_too_large

415`unsupported_audio_type` : The file's MIME type is not one of the accepted audio types (see the `file` field).

One documented failure

  • unsupported_audio_type

    Audio type not allowed.

    unsupported_audio_type

500`internal_server_error` : Internal server error.

One documented failure

  • internal_server_error

    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

    internal_server_error

Error handling

A 400 is returned: - no_audio_uploaded : No audio file was provided in the file field.

  • speech_to_text_disabled : Speech-to-text isn't enabled in the app's published configuration. Calling a Chatflow or Workflow app that hasn't been published yet returns this code too.
  • provider_not_initialize : The workspace has no default speech-to-text model, or the default one has no credentials configured.
  • invalid_param : The default speech-to-text model is disabled in the model provider settings, or the model provider it belongs to is no longer installed.
  • model_currently_not_support : On Dify Cloud, the workspace has used up its paid AI credits, and the trial credits it falls back to don't cover its default speech-to-text model.
  • completion_request_error : The model provider rejected the transcription request or failed to complete it, for example because of invalid credentials. A 413 is returned: audio_too_large : The audio file exceeds the 30 MB size limit. A 415 is returned: unsupported_audio_type : The file's MIME type is not one of the accepted audio types (see the file field). A 500 is returned: internal_server_error : Internal server error.