opendatalab/MinerU

LiteLLM 使用配置

Opened this issue · 2 comments

🔎 Search before asking | 提交之前请先搜索

  • I have searched the MinerU Readme and found no similar bug report.
  • I have searched the MinerU Issues and found no similar bug report.
  • I have searched the MinerU Discussions and found no similar bug report.

🤖 Consult the online AI assistant for assistance | 在线 AI 助手咨询

Description of the bug | 错误描述

我用LiteLLM搭建了LLM proxy, 在config 中这么配置:

 "llm-aided-config": {
        "title_aided": {
            "api_key": "sk-1234",
            "base_url": "https://localhost:4000",
            "model": "gpt-4o",
            "enable": true
        }
    },

显示
File "/home/peiyao.li/Projects/BioAgents/.venv/lib/python3.12/site-packages/openai/_base_client.py", line 1014, in request
raise APIConnectionError(request=request) from err
│ └ <Request('POST', 'https://localhost:4000/chat/completions')>
└ <class 'openai.APIConnectionError'>

How to reproduce the bug | 如何复现

No comment

Operating System Mode | 操作系统类型

Linux

Operating System Version| 操作系统版本

Rocky9

Python version | Python 版本

No response

Software version | 软件版本 (mineru --version)

No response

Device mode | 设备模式

No response

Hi @peiyaoli! I'm Dosu and I’m helping the MinerU team.

你的配置和报错信息显示 MinerU 在尝试连接 LiteLLM proxy 时遇到了 APIConnectionError,这通常是因为网络无法访问、URL 配置错误、服务未启动或 SSL 证书问题导致的。根据 MinerU 的 LLM proxy 相关实现和社区经验,你可以重点排查以下几个方面:

  1. base_url 路径:MinerU 期望 LLM proxy 兼容 OpenAI API,通常需要在 base_url 后加上 /v1 路径,比如 http://localhost:4000/v1,否则会导致接口路径不匹配,连接失败。相关讨论
  2. SSL 证书:你用的是 https://localhost:4000,如果 LiteLLM 没有配置有效的 SSL 证书,或者是自签名证书,openai 客户端会拒绝连接。建议先用 http://localhost:4000/v1 测试,确认服务可用后再考虑 SSL。相关案例
  3. 服务是否启动:确保 LiteLLM proxy 已经在本地 4000 端口启动,并且能正常响应 /v1/chat/completions 请求。可以用 curl 或 Postman 测试接口连通性。
  4. model 字段:LiteLLM proxy 需要支持你配置的 gpt-4o 模型名,且该模型已在 proxy 后端正确映射。如果模型名不对,也会导致接口异常。配置参考

建议你:

  • 先将 base_url 改为 http://localhost:4000/v1 试试;
  • 检查 LiteLLM proxy 日志,确认是否有收到请求或报错;
  • 用 curl 测试 http://localhost:4000/v1/chat/completions 是否能正常返回结果;
  • 如果必须用 https,确保 SSL 证书有效,或在 openai 客户端配置忽略证书校验(不推荐生产环境)。

MinerU 的 LLM-aided 配置只要兼容 OpenAI 协议的 proxy 都可以用,但路径和证书问题是本地部署最常见的坑。官方配置说明

如还有问题,欢迎补充 LiteLLM proxy 的启动参数和日志信息。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@peiyaoli 请问Litellm+mineru的问题解决了吗?能否分享下经验?