[PR #10309] [MERGED] feat: add Google Imagen/Gemini API image generation #9287

Closed
opened 2025-11-11 18:18:44 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/10309
Author: @JoaoCostaIFG
Created: 2/18/2025
Status: Merged
Merged: 2/19/2025
Merged by: @tjbck

Base: devHead: gemini_image_gen


📝 Commits (2)

  • e56b5c0 feat: add Google Imagen/Gemini API image generation
  • 918764a fix: Use x-goog-api-key header for Gemini image generation

📊 Changes

4 files changed (+105 additions, -0 deletions)

View changed files

📝 backend/open_webui/config.py (+14 -0)
📝 backend/open_webui/main.py (+5 -0)
📝 backend/open_webui/routers/images.py (+64 -0)
📝 src/lib/components/admin/Settings/Images.svelte (+22 -0)

📄 Description

Adds support for Gemini API as an image generation backend. By setting the API Base URL to something like 'https://generativelanguage.googleapis.com/v1beta' and providing their API Key, users should be able to start generating images using models like 'imagen-3.0-generate-002'.

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Discussion here (not started by me).

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • Adds support for image generation using Google's Imagen/Gemini API

Added

  • Adds the following config values:
    • Gemini Images API Base URL
    • Gemini Images API Key

Changed

  • N/A

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • N/A

Security

  • N/A

Breaking Changes

  • None

Additional Information

  • This Google API doesn't seem to be documented, so I just investigated what endpoint is used in their genai lib
  • There doesn't seem to be a way to control the size/resolution of the generated image

Screenshots or Videos

  • image

🔄 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/10309 **Author:** [@JoaoCostaIFG](https://github.com/JoaoCostaIFG) **Created:** 2/18/2025 **Status:** ✅ Merged **Merged:** 2/19/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `gemini_image_gen` --- ### 📝 Commits (2) - [`e56b5c0`](https://github.com/open-webui/open-webui/commit/e56b5c063ca72fb5fa3f37965730b63e078a42bd) feat: add Google Imagen/Gemini API image generation - [`918764a`](https://github.com/open-webui/open-webui/commit/918764a4f7093ec0838ceeff358356e0942978e6) fix: Use x-goog-api-key header for Gemini image generation ### 📊 Changes **4 files changed** (+105 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+14 -0) 📝 `backend/open_webui/main.py` (+5 -0) 📝 `backend/open_webui/routers/images.py` (+64 -0) 📝 `src/lib/components/admin/Settings/Images.svelte` (+22 -0) </details> ### 📄 Description Adds support for Gemini API as an image generation backend. By setting the API Base URL to something like 'https://generativelanguage.googleapis.com/v1beta' and providing their API Key, users should be able to start generating images using models like 'imagen-3.0-generate-002'. # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. Discussion [here](https://github.com/open-webui/open-webui/discussions/10029) (not started by me). **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [ ] **Testing:** Have you written and run sufficient tests for validating the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - Adds support for image generation using Google's Imagen/Gemini API ### Added - Adds the following config values: - Gemini Images API Base URL - Gemini Images API Key ### Changed - N/A ### Deprecated - N/A ### Removed - N/A ### Fixed - N/A ### Security - N/A ### Breaking Changes - None --- ### Additional Information - This Google API doesn't seem to be documented, so I just investigated what endpoint is used in their [genai lib](https://pypi.org/project/google-genai/) - There doesn't seem to be a way to control the size/resolution of the generated image ### Screenshots or Videos - ![image](https://github.com/user-attachments/assets/1f8e503d-e8f7-41f8-a4f8-1ca00a4a1a5b) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 18:18:44 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#9287