Calling an endpoint when using a MinerU model catalog
After creating an endpoint by using a MinerU model catalog, you can call the endpoint’s OpenAI-compatible API through the model gateway, or use the official MinerU pipeline client to call the endpoint for document parsing.
Prerequisites
- You have obtained the API URL of the endpoint. For details, see Getting the API URL.
- You have created an API key that can call the endpoint. For details, see Creating an API key.
Precaution
- All calls access the endpoint through the model gateway. The address format is
http://<gateway>/workspace/<workspace>/endpoint/<endpoint>. - The request header must include
Authorization: Bearer <api_key>, where<api_key>is the API key. - When creating an endpoint by using a MinerU model catalog, the model registry and model name are still required, but they do not take effect for the MinerU image. You can select any valid values to pass validation. The selected values do not affect the deployment result.
- The default MinerU model ID is
mineru-2.5. To change the model ID, configureserved_model_namein the engine variables. The corresponding startup parameter is--served-model-name. - MinerU uses
gpu_memory_utilization=0.9by default. The corresponding startup parameter is--gpu-memory-utilization 0.9. To adapt to GPU splitting scenarios, adjustgpu_memory_utilizationin the engine variables.
Calling the OpenAI-compatible API
Section titled “Calling the OpenAI-compatible API”-
Run the following command to obtain the model ID:
Terminal window curl <API_URL>/v1/models \-H "Authorization: Bearer <api_key>"If the model ID has not been adjusted through
served_model_name, the default model ID ismineru-2.5. -
Run the following command to initiate a single-image recognition request through the OpenAI-compatible API.
-
Use Base64-encoded image data.
Terminal window curl <API_URL>/v1/chat/completions \-H "Authorization: Bearer <api_key>" \-H "Content-Type: application/json" \-d '{"model": "mineru-2.5","messages": [{"role": "user","content": [{"type": "image_url","image_url": { "url": "data:image/png;base64,'"$IMG_B64"'" }},{"type": "text","text": "OCR this image, output only the text."}]}]}'On Linux, use
IMG_B64=$(base64 -w0 <image_file>). On macOS, useIMG_B64=$(base64 -i <image_file>). Replace<image_file>with the image file to recognize.If the model ID has been adjusted through
served_model_name, replacemodelin the request body with the actual model ID. -
Specify an image URL.
If the MinerU server can access the image URL, you can specify the image URL directly.
Terminal window curl -s -X POST \"<API_URL>/v1/chat/completions" \-H "Authorization: Bearer <api_key>" \-H "Content-Type: application/json" \-d '{"model": "mineru-2.5","messages": [{"role": "user","content": [{"type": "image_url","image_url": {"url": "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png"}},{"type": "text","text": "OCR this image, output only the text."}]}]}' | jq -r '.choices[0].message.content'If the model ID has been adjusted through
served_model_name, replacemodelin the request body with the actual model ID.
-
-
After the request succeeds, the text in the image is returned.
Calling the official MinerU pipeline client
Section titled “Calling the official MinerU pipeline client”Run the following command to use the official MinerU pipeline client to call the endpoint and parse an entire PDF into Markdown:
export MINERU_VL_API_KEY=<api_key>mineru -p <pdf_file> -o <output_dir> -b vlm-http-client -u <API_URL>/Replace <pdf_file> with the PDF file to parse, and replace <output_dir> with the output directory for the parsing result.