欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > 对接RAGflow的API接口报错

对接RAGflow的API接口报错

2025/12/21 4:37:38 来源:https://blog.csdn.net/xuukai/article/details/146124434  浏览:    关键词:对接RAGflow的API接口报错

对接RAGflow的API接口,报错:

{"status":"success","message":"API连接正常","response":{"code":109,"data":false,"message":"Authentication error: API key is invalid!"}}

可能原因

  • 未提供 API Key:请求头中缺少 Authorization 字段。

  • API Key 格式错误:未按照 Bearer <YOUR_API_KEY> 格式填写。

排查,使用脚本测试:

import httpx
import asyncioasync def test_ragflow_api():api_key = "ragflow-JXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"base_url = "http://1.1.1.1:80"# 测试获取数据集列表async with httpx.AsyncClient() as client:headers = {"Authorization": f"Bearer {api_key}","Content-Type": "application/json"}# 测试 GET /api/v1/datasetsresponse = await client.get(f"{base_url}/api/v1/datasets",headers=headers)print(f"状态码: {response.status_code}")print(f"响应内容: {response.text}")if __name__ == "__main__":asyncio.run(test_ragflow_api())

回复响应:

状态码: 200
响应内容: {"code":0,"data":[{"avatar":"","chunk_count":23477,"chunk_method":"naive","create_date":"Wed, 05 Mar 2025 20:01:47 GMT","create_time":1741176107637,"created_by":"95ebec74f9b911efaecd0242ac130006","description":"GMP\u77e5\u8bc6\u5e93","document_count":559,"embedding_model":"BAAI/bge-large-zh-v1.5@BAAI","id":"9d600508f9b911ef94c20242ac130006","language":"Chinese","name":"GMP\u77e5\u8bc6\u5e93","pagerank":20,"parser_config":{"auto_keywords":5,"auto_questions":2,"chunk_token_num":128,"delimiter":"\\n!?;\u3002\uff1b\uff01\uff1f","graphrag":{"entity_types":["organization","person","geo","event","category"],"method":"light","use_graphrag":true},"html4excel":true,"layout_recognize":"DeepDOC","raptor":{"use_raptor":false}},"permission":"team","similarity_threshold":0.2,"status":"1","tenant_id":"95ebec74f9b911efaecd0242ac130006","token_num":1736587,"update_date":"Sat, 08 Mar 2025 22:03:32 
GMT","update_time":1741442612144,"vector_similarity_weight":0.3}]}

API调用成功了:

1. 状态码是200,表示请求成功
2. 响应内容是一个JSON对象,包含了数据集列表信息:
   - code: 0 (表示成功)
   - data: 包含了一个数据集的详细信息
   - 数据集信息包括:
     - name: "知识库"
     - chunk_count: 23477
     - document_count: 559
     - language: "Chinese"
     - embedding_model: "BAAI/bge-large-zh-v1.5@BAAI"
       等

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词