gemini openai兼容模式怎么用?

正常的chat功能都是好的,但是往open webui里面添加的时候就会提示"OpenAl: Network Problem 大概长这样

贴一个官方的兼容说明,不想装管道,有办法能直接用吗?

openwebui日志:
ERROR [open_webui.routers.openai] Unexpected error: HTTP Error: 404
Traceback (most recent call last):
File “/app/backend/open_webui/routers/openai.py”, line 442, in get_models
raise Exception(error_detail)
Exception: HTTP Error: 404
INFO: MY IP:0 - “GET /openai/models/5 HTTP/1.1” 500 Internal Server Error
ERROR [open_webui.routers.openai] Unexpected error: HTTP Error: 404
Traceback (most recent call last):
File “/app/backend/open_webui/routers/openai.py”, line 512, in verify_connection
raise Exception(error_detail)
Exception: HTTP Error: 404
INFO: MY IP:0 - “POST /openai/verify HTTP/1.1” 500 Internal Server Error

1 个赞

回退到5.0一下

用openai的格式查可用模型也会报错,401 UNAUTHENTICATED

curl https://generativelanguage.googleapis.com/v1beta/models -H “Authorization: Bearer key=APIKEY”

0.5也试过,都不行

可以试试 大佬的这个函数: https://linux.do/t/topic/292141/156

1 个赞

@F-dorid 大佬发了个抱脸的转换space,转成openai格式

感谢,但是我希望不转换直接发请求。gemini不是已经支持openai的格式了吗

感谢,市场上类似的管道还挺多的,但就希望不装插件直接请求

这样啊,那估计要翻翻google的api文档了

google没有给api文档。。。只有一页demo OpenAI compatibility  |  Gemini API  |  Google AI for Developers

如果报500应该是正常的,google官方有时候是会抽风一段时间,过段时间应该会好。

大概可能已经一个月了,从google刚宣布兼容openai格式的时候我就试了

我是说google每天都会有某些时间段抽风,可以隔几个小时再试试,实在不行可以先用个curl请求一下

明白了,但是我用openai的格式去获取模型列表,一直都是401,会不会是gemini兼容没有写完?

{
“error”: {
“code”: 401,
“message”: “Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.”,
“status”: “UNAUTHENTICATED”
}
}

试试这个:point_down:
https://linux.do/t/topic/318726

谢谢大佬的工具,但我希望能直接请求,不套中转和管道

官方还不完全兼容,不套中转或者管道那是不可能的,至少会有一堆问题

1 个赞


对话可以,模型列表暂时获取不了,要手动加,对话可以

1 个赞

这个openai兼容的接口其实一点都不好用,它只能接受chat接口并且不支持任何llm参数,只能用默认参数访问,而且非常容易崩溃,很长时间也没有更新

1 个赞

明白了,那可能他的测试连接性就用的获取模型api,才导致一直不通。