-
Notifications
You must be signed in to change notification settings - Fork 2.2k
读图用哪个接口? #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
from openai import OpenAI
client = OpenAI(
# 输入转发API Key
api_key="sk-xxxxx",
base_url="https://api.chatanywhere.tech/v1"
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "介绍一下这张图"},
{
"type": "image_url",
"image_url": {
"url": "https://lmg.jj20.com/up/allimg/1114/0G020114924/200G0114924-11-1200.jpg",#如果非图片url需要把本地图片转为Base64后,然后把base64的字符串放到这个参数上
"detail": "high" #low high两个选项
}
},
],
}
],
max_tokens=300,
stream=False # # 是否开启流式输出
)
# 非流式输出获取结果
print(response.choices[0].message)
# 流式输出获取结果
# for chunk in response:
# print(chunk.choices[0].delta) |
感谢,调用确实成功了。 |
是的, 免费的不支持读图. 因为读图的费用比较高一些. 如果您需要使用读图功能可以在https://api.chatanywhere.tech/#/shop这里面购买付费api |
好的。 2、另外,我这里的脚本不能引入 3、detail这个参数是有什么含义? |
1.对 |
感谢解答 |
客气, 如没其他问题记得Close一下哈 |
需求是分析图片元素。
所以上传一张图片,然后告知ai需要分析的内容。
ai把分析结果回复给我,是以文字的形式,不需要生成新的图片。
比如说:这张图片里面有几只羊?
我看到gpt-4o-mini的介绍,有读图功能。
但是怎么用?
我尝试调用/chat/completions接口,把图片转成base64再以文本的方式发送,回复我消息过长403。
然后我尝试把请求头改成multipart/form-data,以文件的形式发送(文字描述放prompt里面),报500。
role: "system",
image: outputFile,
prompt:message
500 {'error':{'message':'服务器繁忙,请稍后再试!','type':'chatanywhere_error','param':null,'code':'500 INTERNAL_SERVER_ERROR'}}
尝试将接口换成/images/edits,也是500
我该怎么办?
The text was updated successfully, but these errors were encountered: