{"record":{"id":"6fd4af1d91eebaa1","repo":"langgenius/dify","slug":"completion-request-error","errorCode":"completion_request_error","errorMessage":"Completion request failed.","messagePattern":"Completion request failed\\.","errorType":"error_code","errorClass":"CompletionRequestError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/app/audio.py","lineNumber":171,"sourceCode":"        raise AppUnavailableError()\n    except NoAudioUploadedServiceError:\n        raise NoAudioUploadedError()\n    except AudioTooLargeServiceError as e:\n        raise AudioTooLargeError(str(e))\n    except UnsupportedAudioTypeServiceError:\n        raise UnsupportedAudioTypeError()\n    except ProviderNotSupportSpeechToTextServiceError:\n        raise ProviderNotSupportSpeechToTextError()\n    except SpeechToTextDisabledServiceError:\n        raise SpeechToTextDisabledError()\n    except ProviderTokenNotInitError as ex:\n        raise ProviderNotInitializeError(ex.description)\n    except QuotaExceededError:\n        raise ProviderQuotaExceededError()\n    except ModelCurrentlyNotSupportError:\n        raise ProviderModelCurrentlyNotSupportError()\n    except InvokeError as e:\n        raise CompletionRequestError(e.description)\n    except HTTPException:\n        raise\n    except ValueError:\n        raise\n    except Exception as e:\n        logger.exception(\"Failed to transcribe audio to text\")\n        raise InternalServerError() from e\n\n\n@console_ns.route(\"/apps/<uuid:app_id>/audio-to-text\")\nclass ChatMessageAudioApi(Resource):\n    @console_ns.doc(\"chat_message_audio_transcript\")\n    @console_ns.doc(description=\"Transcript audio to text for chat messages\")\n    @console_ns.doc(\n        consumes=[\"multipart/form-data\"],\n        params={\"app_id\": \"App ID\", \"file\": _AUDIO_TRANSCRIPT_FILE_PARAM},\n    )\n    @console_ns.response(","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/audio.py#L153-L189","documentation":"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').","triggerScenarios":"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.","commonSituations":"Provider API key rotated but not updated in Dify; upstream outage; rate-limited provider account; transient connectivity from the Dify node to the provider.","solutions":["Retry the request after a short backoff — many InvokeError causes are transient.","Verify provider credentials are valid and have credit/quota under Settings -> Model Provider.","Check the provider's status page for outages.","Inspect the wrapped e.description in the response for provider-specific detail and address accordingly."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function transcribeWithRetry(form, retries = 2) {\n  for (let i = 0; i <= retries; i++) {\n    try { return await axios.post(`/apps/${id}/audio-to-text`, form); }\n    catch (e) {\n      if (e.code === 'completion_request_error' && i < retries) { await backoff(i); continue; }\n      throw e;\n    }\n  }\n}","preventionTips":["Validate provider credentials and quota before relying on STT.","Inspect e.description in the response for upstream detail.","Retry with exponential backoff for transient InvokeError causes."],"tags":["audio","asr","model-provider","network","retry","console-api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}