调用api时,如何从本地读取图片
Closed this issue · 3 comments
yutmdfeng commented
System Info / 系統信息
zhipuai.core._errors.APIRequestFailedError: Error code: 400, with error text {"error":{"code":"1210","message":"图片输入格式/解析错误"}}
Information / 问题信息
- The official example scripts / 仓库中的示例脚本
- My own modified scripts / 我自己修改的脚本和任务
Reproduction / 复现过程
local_image_path = "C:/Users/admin/OneDrive/pic/download/rail/Snipaste_2024-04-18_21-33-56.png"
response = client.chat.completions.create(
model="glm-4v", # 填写需要调用的模型名称
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "图里有什么"
},
{
"type": "image_url",
"image_url": {
"url" : local_image_path
}
}
]
}
]
)
Expected behavior / 期待表现
如何从本地上传图片进行推理
zRzRzRzRzRzRzR commented
用base64
yutmdfeng commented
zhipuai.core._errors.APIAuthenticationError: Error code: 401, with error text {"error":{"code":"1003","message":"Authorization Token已过期,请重新生成/获取。"}}
这个Authorization Token如何重新生成
zRzRzRzRzRzRzR commented
查看对应API文档教程