mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 02:15:22 -04:00
How to get the file url in LargeLanguageModel? #65
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sweetwxh on GitHub (Dec 4, 2025).
When passing a video file into an LLM node, the input is as follows:
{
"#files#": [
{
"dify_model_identity": "dify__file",
"id": null,
"tenant_id": "ebfc4fce-084a-4fea-8f62-ff0464f4ca79",
"type": "video",
"transfer_method": "local_file",
"remote_url": "",
"related_id": "16c33ddf-d0bd-4dec-90d6-a39856fe4037",
"filename": "1.mp4",
"extension": ".mp4",
"mime_type": "video/mp4",
"size": 1471368,
"url": ""
}
]
}
Within a custom Model provider, can the parameter prompt_messages inside LargeLanguageModel._invoke obtain the URL of the input file (VideoPromptMessageContent)?
@Mairuis commented on GitHub (Dec 8, 2025):
Hi @sweetwxh,
Thanks for raising this question. Based on the SDK and Dify core code, here's how you can get the file URL in your custom LLM provider:
How it works
When files are passed to an LLM node, Dify converts them to
PromptMessageContentobjects (likeVideoPromptMessageContent). TheMultiModalPromptMessageContentbase class has bothurlandbase64_datafields:Getting the URL in your LargeLanguageModel._invoke
In your
_invokemethod, you can access the file content like this:Important: MULTIMODAL_SEND_FORMAT configuration
Whether you get a URL or base64 data depends on the
MULTIMODAL_SEND_FORMATenvironment variable in Dify:MULTIMODAL_SEND_FORMAT=base64(default): Files are sent as base64-encoded dataMULTIMODAL_SEND_FORMAT=url: Files are sent as signed URLsIf you need URLs, you'll need to set
MULTIMODAL_SEND_FORMAT=urlin your Dify deployment's environment configuration.Hope this helps! Let me know if you have any further questions.