This PR adds support for Google's embedding models (Gemini) to Open WebUI's RAG functionality. Previously, users trying to use Google embeddings would encounter "Unknown embedding engine: google" errors.
Changes Made
Core Implementation
Added google to the supported embedding engines list in get_embedding_function()
Implemented generate_google_batch_embeddings() function following Google's API specification
Added proper error handling and logging for Google embedding requests
Technical Details
Endpoint: Uses Google's native models/{model}:batchEmbedContents API endpoint
Authentication: Supports x-goog-api-key header format
Request Format: Handles Google's specific request structure with requests array
Response Parsing: Extracts embeddings from Google's {"embeddings": [{"values": [...]}]} response format
Testing
✅API Verification: Direct API calls to Google's embedding service succeed ✅Integration Testing: Open WebUI starts successfully with RAG_EMBEDDING_ENGINE=google ✅Error Resolution: No more "Unknown embedding engine" errors ✅Model Recognition: Properly recognizes models like text-embedding-004
Configuration Example
environment:- RAG_EMBEDDING_ENGINE=google- RAG_EMBEDDING_MODEL=text-embedding-004- OPENAI_API_KEY=${GOOGLE_API_KEY} # Use Google API key
Enables RAG functionality with Google's multilingual embedding models
Supports Google's latest text-embedding-004 model (768 dimensions)
Maintains compatibility with existing OpenAI/Ollama/Azure implementations
Provides proper error handling and logging
Backwards Compatibility
This change is fully backwards compatible. Existing configurations continue to work unchanged.
Type of Change
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Documentation update
Checklist
My code follows the style guidelines of this project
I have performed a self-review of my code
My changes generate no new warnings
I have tested my changes locally
The changes have been tested with actual Google API keys
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.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/16022
**Author:** [@ipapapa](https://github.com/ipapapa)
**Created:** 7/25/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `fix-google-embeddings`
---
### 📝 Commits (4)
- [`ffff6fa`](https://github.com/open-webui/open-webui/commit/ffff6fa23af9288a6e669129000600a86de3032c) feat: Add Google embeddings support
- [`b8da4a8`](https://github.com/open-webui/open-webui/commit/b8da4a8cd8257d4846f3608e299618a0b4f185ed) refac
- [`d7262aa`](https://github.com/open-webui/open-webui/commit/d7262aa2c9f2f38eaedd7bf44ad5ae2c1ad306c1) Merge branch 'open-webui:main' into fix-google-embeddings
- [`b21509d`](https://github.com/open-webui/open-webui/commit/b21509d445c2005f662ca6fd46ec0ddee260cd2e) feat: Add Google embeddings support with migration guidance
### 📊 Changes
**6 files changed** (+190 additions, -19 deletions)
<details>
<summary>View changed files</summary>
📝 `README.md` (+41 -0)
📝 `backend/open_webui/config.py` (+0 -6)
📝 `backend/open_webui/env.py` (+29 -0)
📝 `backend/open_webui/main.py` (+1 -1)
📝 `backend/open_webui/retrieval/utils.py` (+64 -1)
📝 `backend/open_webui/utils/auth.py` (+55 -11)
</details>
### 📄 Description
# Add Google embeddings support
## Summary
This PR adds support for Google's embedding models (Gemini) to Open WebUI's RAG functionality. Previously, users trying to use Google embeddings would encounter "Unknown embedding engine: google" errors.
## Changes Made
### Core Implementation
- Added `google` to the supported embedding engines list in `get_embedding_function()`
- Implemented `generate_google_batch_embeddings()` function following Google's API specification
- Added proper error handling and logging for Google embedding requests
### Technical Details
- **Endpoint**: Uses Google's native `models/{model}:batchEmbedContents` API endpoint
- **Authentication**: Supports `x-goog-api-key` header format
- **Request Format**: Handles Google's specific request structure with `requests` array
- **Response Parsing**: Extracts embeddings from Google's `{"embeddings": [{"values": [...]}]}` response format
## Testing
✅ **API Verification**: Direct API calls to Google's embedding service succeed
✅ **Integration Testing**: Open WebUI starts successfully with `RAG_EMBEDDING_ENGINE=google`
✅ **Error Resolution**: No more "Unknown embedding engine" errors
✅ **Model Recognition**: Properly recognizes models like `text-embedding-004`
## Configuration Example
```yaml
environment:
- RAG_EMBEDDING_ENGINE=google
- RAG_EMBEDDING_MODEL=text-embedding-004
- OPENAI_API_KEY=${GOOGLE_API_KEY} # Use Google API key
```
## Related Issues
Discussion: https://github.com/open-webui/open-webui/discussions/16043
Closes #11714
## Benefits
- Enables RAG functionality with Google's multilingual embedding models
- Supports Google's latest text-embedding-004 model (768 dimensions)
- Maintains compatibility with existing OpenAI/Ollama/Azure implementations
- Provides proper error handling and logging
## Backwards Compatibility
This change is fully backwards compatible. Existing configurations continue to work unchanged.
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [x] I have tested my changes locally
- [x] The changes have been tested with actual Google API keys
## Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16022
Author: @ipapapa
Created: 7/25/2025
Status: ❌ Closed
Base:
dev← Head:fix-google-embeddings📝 Commits (4)
ffff6fafeat: Add Google embeddings supportb8da4a8refacd7262aaMerge branch 'open-webui:main' into fix-google-embeddingsb21509dfeat: Add Google embeddings support with migration guidance📊 Changes
6 files changed (+190 additions, -19 deletions)
View changed files
📝
README.md(+41 -0)📝
backend/open_webui/config.py(+0 -6)📝
backend/open_webui/env.py(+29 -0)📝
backend/open_webui/main.py(+1 -1)📝
backend/open_webui/retrieval/utils.py(+64 -1)📝
backend/open_webui/utils/auth.py(+55 -11)📄 Description
Add Google embeddings support
Summary
This PR adds support for Google's embedding models (Gemini) to Open WebUI's RAG functionality. Previously, users trying to use Google embeddings would encounter "Unknown embedding engine: google" errors.
Changes Made
Core Implementation
googleto the supported embedding engines list inget_embedding_function()generate_google_batch_embeddings()function following Google's API specificationTechnical Details
models/{model}:batchEmbedContentsAPI endpointx-goog-api-keyheader formatrequestsarray{"embeddings": [{"values": [...]}]}response formatTesting
✅ API Verification: Direct API calls to Google's embedding service succeed
✅ Integration Testing: Open WebUI starts successfully with
RAG_EMBEDDING_ENGINE=google✅ Error Resolution: No more "Unknown embedding engine" errors
✅ Model Recognition: Properly recognizes models like
text-embedding-004Configuration Example
Related Issues
Discussion: https://github.com/open-webui/open-webui/discussions/16043
Closes #11714
Benefits
Backwards Compatibility
This change is fully backwards compatible. Existing configurations continue to work unchanged.
Type of Change
Checklist
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.