mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 07:46:16 -05:00
[GH-ISSUE #12212] issue: 连接外部api失败,OpenAI: Network Problem?? #103504
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tonycheungzyz on GitHub (Mar 31, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12212
Check Existing Issues
Installation Method
Pip Install
Open WebUI Version
0.5.19-0.5.20
Ollama Version (if applicable)
No response
Operating System
windows10 and ubuntu
Browser (if applicable)
Chrome
Confirmation
README.md.Expected Behavior
使用外部api
Actual Behavior
OpenAI: Network Problem
Steps to Reproduce
1、管理员面板--外部连接 open ai api
2、url https://ark.cn-beijing.volces.com/api/v3
密钥:a6xxxxx-xxxx-xxxx-xxx-xxxxxxxx
模型id:xxxx
验证连接时提示:OpenAI: Network Problem
Logs & Screenshots
控制台报错:
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "D:\open_webui.venv\Scripts\open-webui.exe_main_.py", line 10, in
sys.exit(app())
│ │ └ <typer.main.Typer object at 0x000002625A1C0890>
│ └
└ <module 'sys' (built-in)>
File "D:\open_webui.venv\Lib\site-packages\typer\main.py", line 322, in call
return get_command(self)(*args, **kwargs)
│ │ │ └ {}
│ │ └ ()
│ └ <typer.main.Typer object at 0x000002625A1C0890>
└ <function get_command at 0x000002625E2D6FC0>
File "D:\open_webui.venv\Lib\site-packages\click\core.py", line 1161, in call
return self.main(args, **kwargs)
│ │ │ └ {}
│ │ └ ()
│ └ <function TyperGroup.main at 0x000002625E24B9C0>
└
File "D:\open_webui.venv\Lib\site-packages\typer\core.py", line 740, in main
return _main(
└ <function _main at 0x000002625E24AC00>
File "D:\open_webui.venv\Lib\site-packages\typer\core.py", line 195, in _main
rv = self.invoke(ctx)
│ │ └ <click.core.Context object at 0x000002625E2F6900>
│ └ <function MultiCommand.invoke at 0x000002625C3A4F40>
└
File "D:\open_webui.venv\Lib\site-packages\click\core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
│ │ │ │ └ <click.core.Context object at 0x000002625A351310>
│ │ │ └ <function Command.invoke at 0x000002625C3A4900>
│ │ └
│ └ <click.core.Context object at 0x000002625A351310>
└ <function MultiCommand.invoke.._process_result at 0x000002625E64E7A0>
File "D:\open_webui.venv\Lib\site-packages\click\core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
│ │ │ │ │ └ {'host': '0.0.0.0', 'port': 8080}
│ │ │ │ └ <click.core.Context object at 0x000002625A351310>
│ │ │ └ <function serve at 0x000002625E64E660>
│ │ └
│ └ <function Context.invoke at 0x000002625C393240>
└ <click.core.Context object at 0x000002625A351310>
File "D:\open_webui.venv\Lib\site-packages\click\core.py", line 788, in invoke
return _callback(*args, **kwargs)
│ └ {'host': '0.0.0.0', 'port': 8080}
└ ()
File "D:\open_webui.venv\Lib\site-packages\typer\main.py", line 697, in wrapper
return callback(**use_params)
│ └ {'host': '0.0.0.0', 'port': 8080}
└ <function serve at 0x000002625E4A7BA0>
File "D:\open_webui.venv\Lib\site-packages\open_webui_init.py", line 77, in serve
uvicorn.run(open_webui.main.app, host=host, port=port, forwarded_allow_ips="")
│ │ │ │ │ │ └ 8080
│ │ │ │ │ └ '0.0.0.0'
│ │ │ │ └ <fastapi.applications.FastAPI object at 0x000002627C4510D0>
│ │ │ └ <module 'open_webui.main' from 'D:\open_webui\.venv\Lib\site-packages\open_webui\main.py'>
│ │ └ <module 'open_webui' from 'D:\open_webui\.venv\Lib\site-packages\open_webui\init.py'>
│ └ <function run at 0x000002625E4A7B00>
└ <module 'uvicorn' from 'D:\open_webui\.venv\Lib\site-packages\uvicorn\init.py'>
File "D:\open_webui.venv\Lib\site-packages\uvicorn\main.py", line 579, in run
server.run()
│ └ <function Server.run at 0x000002625E4A7D80>
└ <uvicorn.server.Server object at 0x0000026210E745F0>
File "D:\open_webui.venv\Lib\site-packages\uvicorn\server.py", line 66, in run
return asyncio.run(self.serve(sockets=sockets))
│ │ │ │ └ None
│ │ │ └ <function Server.serve at 0x000002625E4A7E20>
│ │ └ <uvicorn.server.Server object at 0x0000026210E745F0>
│ └ <function run at 0x000002625E2D7EC0>
└ <module 'asyncio' from 'C:\Program Files\Python312\Lib\asyncio\init.py'>
File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
│ │ └ <coroutine object Server.serve at 0x000002625E607760>
│ └ <function Runner.run at 0x000002625E40D1C0>
└ <asyncio.runners.Runner object at 0x0000026210E115E0>
File "C:\Program Files\Python312\Lib\asyncio\runners.py", line 118, in run
return self.loop.run_until_complete(task)
│ │ │ └ <Task pending name='Task-1' coro=<Server.serve() running at D:\open_webui.venv\Lib\site-packages\uvicorn\server.py:70> wait...
│ │ └ <function BaseEventLoop.run_until_complete at 0x000002625E402DE0>
│ └
└ <asyncio.runners.Runner object at 0x0000026210E115E0>
File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 674, in run_until_complete
self.run_forever()
│ └ <function ProactorEventLoop.run_forever at 0x000002625E447C40>
└
File "C:\Program Files\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
super().run_forever()
File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
self._run_once()
│ └ <function BaseEventLoop._run_once at 0x000002625E40CB80>
└
File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 1987, in _run_once
handle._run()
│ └ <function Handle._run at 0x000002625E395080>
└ <Handle Task.task_wakeup()>
File "C:\Program Files\Python312\Lib\asyncio\events.py", line 88, in _run
self._context.run(self._callback, *self._args)
│ │ │ │ │ └ <member '_args' of 'Handle' objects>
│ │ │ │ └ <Handle Task.task_wakeup()>
│ │ │ └ <member '_callback' of 'Handle' objects>
│ │ └ <Handle Task.task_wakeup()>
│ └ <member '_context' of 'Handle' objects>
└ <Handle Task.task_wakeup()>
File "D:\open_webui.venv\Lib\site-packages\starlette\middleware\base.py", line 141, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
│ │ │ │ └ <function BaseHTTPMiddleware.call..call_next..send_no_error at 0x0000026212145080>
│ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ └ <starlette.middleware.exceptions.ExceptionMiddleware object at 0x0000026210EC89B0>
└ <open_webui.main.RedirectMiddleware object at 0x000002620FAD4080>
File "D:\open_webui.venv\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
│ │ │ │ │ │ └ <function BaseHTTPMiddleware.call..call_next..send_no_error at 0x0000026212145080>
│ │ │ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ │ │ └ <starlette.requests.Request object at 0x000002621233B7D0>
│ │ └ <fastapi.routing.APIRouter object at 0x000002627C467AD0>
│ └ <starlette.middleware.exceptions.ExceptionMiddleware object at 0x0000026210EC89B0>
└ <function wrap_app_handling_exceptions at 0x000002626101E160>
File "D:\open_webui.venv\Lib\site-packages\starlette_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
│ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x0000026212144540>
│ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
└ <fastapi.routing.APIRouter object at 0x000002627C467AD0>
File "D:\open_webui.venv\Lib\site-packages\starlette\routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
│ │ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x0000026212144540>
│ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ └ <bound method Router.app of <fastapi.routing.APIRouter object at 0x000002627C467AD0>>
└ <fastapi.routing.APIRouter object at 0x000002627C467AD0>
File "D:\open_webui.venv\Lib\site-packages\starlette\routing.py", line 735, in app
await route.handle(scope, receive, send)
│ │ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x0000026212144540>
│ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ └ <function Route.handle at 0x000002626101F600>
└ APIRoute(path='/openai/verify', name='verify_connection', methods=['POST'])
File "D:\open_webui.venv\Lib\site-packages\starlette\routing.py", line 288, in handle
await self.app(scope, receive, send)
│ │ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x0000026212144540>
│ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ └ <function request_response..app at 0x000002621091E980>
└ APIRoute(path='/openai/verify', name='verify_connection', methods=['POST'])
File "D:\open_webui.venv\Lib\site-packages\starlette\routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
│ │ │ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x0000026212144540>
│ │ │ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ │ │ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
│ │ └ <starlette.requests.Request object at 0x000002621233B200>
│ └ <function request_response..app..app at 0x0000026212145BC0>
└ <function wrap_app_handling_exceptions at 0x000002626101E160>
File "D:\open_webui.venv\Lib\site-packages\starlette_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
│ │ │ └ <function wrap_app_handling_exceptions..wrapped_app..sender at 0x00000262121380E0>
│ │ └ <function BaseHTTPMiddleware.call..call_next..receive_or_disconnect at 0x00000262121442C0>
│ └ {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.3'}, 'http_version': '1.1', 'server': ('127.0.0.1', 8080), 'cl...
└ <function request_response..app..app at 0x0000026212145BC0>
File "D:\open_webui.venv\Lib\site-packages\starlette\routing.py", line 73, in app
response = await f(request)
│ └ <starlette.requests.Request object at 0x000002621233B200>
└ <function get_request_handler..app at 0x000002621091F880>
File "D:\open_webui.venv\Lib\site-packages\fastapi\routing.py", line 301, in app
raw_response = await run_endpoint_function(
└ <function run_endpoint_function at 0x000002626101DEE0>
File "D:\open_webui.venv\Lib\site-packages\fastapi\routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
│ │ └ {'user': UserModel(id='d2736cf4-8548-45b0-aea0-bc0d3fc411dc', name='志哥本机', email='1@qq.com', role='admin', profile_image_url=...
│ └ <function verify_connection at 0x000002627A6DD080>
└ Dependant(path_params=[], query_params=[], header_params=[], cookie_params=[], body_params=[ModelField(field_info=Body(Pydant...
aiohttp.client_exceptions.ContentTypeError: 404, message='Attempt to decode JSON with unexpected mimetype: ', url='https://ark.cn-beijing.volces.com/api/v3/models'
2025-03-31 11:28:05.557 | INFO | uvicorn.protocols.http.httptools_impl:send:476 - 127.0.0.1:58233 - "POST /openai/verify HTTP/1.1" 500 - {}
Additional Information
使用python可以正常访问该接口:
def get_json_from_api(api_key, endpoint_id):
client = OpenAI(
api_key="与所填密钥一致",
base_url="https://ark.cn-beijing.volces.com/api/v3",
)
completion = client.chat.completions.create(
model="与所填模型id一致",
max_tokens=12288,
response_format={
'type': 'json_object'
},
messages=[
{
"role": "system",
"content": "内容"
},
{
"role": "user",
"content": "提问内容"
}
])