mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-07-22 04:15:24 -04:00
[DOCS]: How to invoke the knowledge base pipeline through API when creating a document via file? #260
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 @xiaohe123456 on GitHub (Oct 31, 2025).
Type of Documentation Change
Other
Documentation Page URL or Path
No response
Current Content
No response
Suggested Changes
In the dify-2.0.0-beta.1 version, after the knowledge base pipeline is created and released, how can documents be created through the API?
Reason for Change
No response
Code of Conduct
@dosubot[bot] commented on GitHub (Oct 31, 2025):
Hi @xiaohe123456! I'm Dosu and I’m helping the dify-docs team.
To create a document via file upload and invoke the knowledge base pipeline through the API in Dify v2.0.0-beta.1, use the endpoint:
Send a multipart/form-data request with two fields:
file: the file to uploaddata: a JSON string with metadata, such asindexing_technique,process_rule, and optionallydoc_formfor hierarchical mode.Include the header:
Example cURL:
After upload, Dify will automatically process and parse the file in the knowledge base pipeline. For advanced pipeline features (like custom extractors), API support may be limited compared to the Web UI, but using a user-scoped API token and matching your
process_ruleto the pipeline config maximizes compatibility. For more details and examples, see this issue and this discussion.If you use the Python SDK, the
KnowledgeBaseClient.upload_pipeline_file()method is designed for this purpose reference.For large files (>800KB), use a Python code node instead of the HTTP request node in Dify workflows reference.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@xiaohe123456 commented on GitHub (Oct 31, 2025):
@dosu When uploading files via API and parsing PDF documents, MinerU was not utilized. Why is that? How can PDF documents be parsed without using MinerU, and what is the accuracy rate in this case?
@dosubot[bot] commented on GitHub (Oct 31, 2025):
MinerU is not used when uploading and parsing PDF documents via the API because the API endpoint (
/v1/datasets/{dataset_id}/document/create-by-file) defaults to Dify's built-in parsing logic and does not reliably trigger the Knowledge Pipeline or custom extractors like MinerU. This is a known limitation—currently, only uploads through the Web UI are guaranteed to use the full pipeline with custom extractors like MinerU. When you upload a PDF via the API, Dify uses its ownPdfExtractorclass, which parses PDFs using thepypdfium2library to extract text from each page (source).The accuracy of this default method is generally good for text-based PDFs, but it does not perform OCR, so it cannot extract text from scanned or image-only PDFs. Complex layouts, tables, and images may not be parsed accurately. For best results, use text-based PDFs and minimize complex formatting. If you need higher accuracy or support for scanned/image PDFs, you would need to process the files externally (for example, with MinerU or another OCR tool) and then upload the extracted text to Dify (reference).
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
