mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-10 23:55:15 -05:00
OpenAI Proxy endpoint "/openai/chat/completions" is broken #3248
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 @McBane87 on GitHub (Jan 11, 2025).
Bug Report
Installation Method
Docker
Environment
Confirmation:
Expected Behavior:
API Proxy/Endpoint
/openai/chat/completionsshould proxy requests to specified model, when doing for example:Actual Behavior:
Instead of doing the wanted task, it gives a
404 - {"detail": "Model not found"}response.Description
Bug Summary:
The bug seems to be caused by:
4269df041f/backend/open_webui/routers/openai.py (L576-L583)Because
request.app.state.OPENAI_MODELSis empty here, it will always fail.My current workaround soltution is to add a
await get_all_models(request)above the mentioned code. This wayrequest.app.state.OPENAI_MODELSgets filled before the check actually gets executed.Reproduction Details
Steps to Reproduce:
See curl command above.
Logs and Screenshots
Browser Console Logs:
Docker Container Logs:
Screenshots/Screen Recordings (if applicable):
None
Additional Information
None
@rgaricano commented on GitHub (Jan 11, 2025):
a doubt,
shouldn't it be
curl https://openwebui.host/openai/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }'?
(I emphasize .../v1/chat/completions)
(https://platform.openai.com/docs/api-reference/making-requests)
@McBane87 commented on GitHub (Jan 11, 2025):
There is no "/v1" route defined in
open-webui/backend/open_webui/routers/openai.py. So I guess no, my approach (without v1) is correct. What also makes me think it's correct: It works, without "v1", if I add my workaround.@tjbck commented on GitHub (Jan 12, 2025):
Fixed with
5d3f778b2a, Thanks!