MetaGLM / glm-cookbook

Examples and guides for using the GLM APIs
https://open.bigmodel.cn/
Apache License 2.0
797 stars 91 forks source link

调用api时,如何从本地读取图片 #21

Closed yutmdfeng closed 6 months ago

yutmdfeng commented 6 months ago

System Info / 系統信息

zhipuai.core._errors.APIRequestFailedError: Error code: 400, with error text {"error":{"code":"1210","message":"图片输入格式/解析错误"}}

Information / 问题信息

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 6 months ago

用base64

yutmdfeng commented 6 months ago

zhipuai.core._errors.APIAuthenticationError: Error code: 401, with error text {"error":{"code":"1003","message":"Authorization Token已过期,请重新生成/获取。"}} 这个Authorization Token如何重新生成

zRzRzRzRzRzRzR commented 6 months ago

查看对应API文档教程