langgenius/dify · error · CompletionRequestError

completion_request_error

completion_request_error

Error message

Completion request failed.

What it means

Raised by _transcribe_audio_to_text when AudioService raises InvokeError — a generic provider invocation failure (network, auth, upstream model error, rate limit inside the provider SDK). The controller wraps the description and translates to CompletionRequestError (400, error_code 'completion_request_error').

Source

Thrown at api/controllers/console/app/audio.py:171

        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 HTTPException:
        raise
    except ValueError:
        raise
    except Exception as e:
        logger.exception("Failed to transcribe audio to text")
        raise InternalServerError() from e


@console_ns.route("/apps/<uuid:app_id>/audio-to-text")
class ChatMessageAudioApi(Resource):
    @console_ns.doc("chat_message_audio_transcript")
    @console_ns.doc(description="Transcript audio to text for chat messages")
    @console_ns.doc(
        consumes=["multipart/form-data"],
        params={"app_id": "App ID", "file": _AUDIO_TRANSCRIPT_FILE_PARAM},
    )
    @console_ns.response(

View on GitHub (pinned to ef8544b173)

Solutions

  1. Retry the request after a short backoff — many InvokeError causes are transient.
  2. Verify provider credentials are valid and have credit/quota under Settings -> Model Provider.
  3. Check the provider's status page for outages.
  4. Inspect the wrapped e.description in the response for provider-specific detail and address accordingly.
Defensive patterns

Strategy: retry

Try / catch

async function transcribeWithRetry(form, retries = 2) {
  for (let i = 0; i <= retries; i++) {
    try { return await axios.post(`/apps/${id}/audio-to-text`, form); }
    catch (e) {
      if (e.code === 'completion_request_error' && i < retries) { await backoff(i); continue; }
      throw e;
    }
  }
}

Prevention

When it happens

Trigger: Any underlying provider call failure during transcription: transient network error, expired API key, upstream 5xx, model-specific runtime error, or upstream rate limit returned via InvokeError.

Common situations: Provider API key rotated but not updated in Dify; upstream outage; rate-limited provider account; transient connectivity from the Dify node to the provider.

Related errors


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