mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[PR #14667] [MERGED] feat: OpenAI-compatible /api/embeddings endpoint with provider-agnostic OpenWebUI architecture
#10342
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/14667
Author: @hdnh2006
Created: 6/4/2025
Status: ✅ Merged
Merged: 6/4/2025
Merged by: @tjbck
Base:
dev← Head:main📝 Commits (7)
0afe972embeddings function added 100% OpenAI compatible4151145Merge branch 'open-webui:main' into maine0769c6new embedding.py added for handling openai and ollama embedding8f6c3f4payload and response modifed for compatibility3ddebefopenai embeddings function modifiedcc12e9eOllama embeddings adapted to pydantic04da2b0convert embedding function name to be more consistence📊 Changes
5 files changed (+321 additions, -0 deletions)
View changed files
📝
backend/open_webui/main.py(+32 -0)📝
backend/open_webui/routers/openai.py(+79 -0)➕
backend/open_webui/utils/embeddings.py(+127 -0)📝
backend/open_webui/utils/payload.py(+31 -0)📝
backend/open_webui/utils/response.py(+52 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
In this PR, I solve this feature request.
With this PR, a new endpoint
/api/embeddingsis introduced to the backend, enabling direct access to the embeddings functionality. This route is fully compatible with OpenAI, Ollama, and pipeline-based embedding providers available in Open WebUI, while preserving the existing/openai/embeddingsroute for backward compatibility. This enhancement streamlines integration by providing a unified and intuitive API for generating embeddings across multiple backends.There's a big difference with my previous, I follow the suggestion of the author in this comment:
For this, my PR:
/api/embeddingsendpoint following the OpenWebUI generic dispatch pattern.Added
/api/embeddingsthat maps to the existing OpenAI embeddings functionalityutils/embeddings.pymodeled afterutils/chat.py.Changed
/api/embeddingsendpoint inmain.pyto use the new, extensible dispatch system.Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
Python code used for testing:
Response gotten:
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.