langgenius/dify · error · CompletionRequestError

completion_request_error

completion_request_error

Error message

Completion request failed.

What it means

HTTP 400 CompletionRequestError, raised by the STT endpoint. The model runtime raised InvokeError during the speech2text call. The controller wraps the upstream error description into this generic 'Completion request failed.' error. InvokeError is the graphon model_runtime base for provider-side invocation failures (auth, rate limit, bad request, server error, content filter, etc.).

Source

Thrown at api/controllers/console/explore/audio.py:89

            raise AppUnavailableError()
        except NoAudioUploadedServiceError:
            raise NoAudioUploadedError()
        except AudioTooLargeServiceError as e:
            raise AudioTooLargeError(str(e))
        except UnsupportedAudioTypeServiceError:
            raise UnsupportedAudioTypeError()
        except ProviderNotSupportSpeechToTextServiceError:
            raise ProviderNotSupportSpeechToTextError()
        except SpeechToTextDisabledServiceError:
            raise SpeechToTextDisabledError()
        except ProviderTokenNotInitError as ex:
            raise ProviderNotInitializeError(ex.description)
        except QuotaExceededError:
            raise ProviderQuotaExceededError()
        except ModelCurrentlyNotSupportError:
            raise ProviderModelCurrentlyNotSupportError()
        except InvokeError as e:
            raise CompletionRequestError(e.description)
        except ValueError as e:
            raise e
        except Exception as e:
            logger.exception("internal server error.")
            raise InternalServerError()


@console_ns.route(
    "/installed-apps/<uuid:installed_app_id>/text-to-audio",
    endpoint="installed_app_text",
)
class ChatTextApi(InstalledAppResource):
    @console_ns.expect(console_ns.models[TextToAudioPayload.__name__])
    @console_ns.response(200, "Success", console_ns.models[AudioBinaryResponse.__name__])
    @model_validate(TextToAudioPayload)
    def post(self, req_data: TextToAudioPayload, installed_app: InstalledApp):
        app_model = installed_app.app_with_session(session=db.session())
        if app_model is None:

View on GitHub (pinned to ef8544b173)

Solutions

  1. Inspect server logs: the caught InvokeError's description (e.description) and the logger.exception trace identify the upstream cause.
  2. If rate-limited, back off and retry with exponential jitter.
  3. If the audio is corrupt, re-record/re-encode and resend.
  4. If the provider is down, retry shortly or fail over to another configured STT provider.
  5. If the key was revoked, re-enter credentials (see error 683).
Defensive patterns

Strategy: retry

Try / catch

async function transcribe(file, attempt = 0) {
  try { return await postAudio(file) }
  catch (e) {
    if (e.code === 400 && e.error_code === 'completion_request_error' && attempt < 2 && isTransient(e))
      return await sleep(2 ** attempt * 500).then(() => transcribe(file, attempt + 1))
    throw e
  }
}

Prevention

When it happens

Trigger: POST /console/explore/installed-apps/{id}/audio-to-text where the speech2text provider accepted the request at the Dify layer but returned an error during invocation: 4xx/5xx from the provider, malformed audio payload the provider rejects, rate-limited by the provider, content-policy rejection, or transient provider outage.

Common situations: Provider rate limit hit; audio bytes valid by MIME but corrupt/truncated so the provider fails to decode; provider temporary 5xx; API key valid at config time but later revoked (surfaces as InvokeError rather than ProviderTokenNotInitError); network blip between Dify and provider.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/f611e9c9ebfa3b0c. Report an issue: GitHub.