{"id":41927689,"url":"https://github.com/huyhvq/google_genai","last_synced_at":"2026-01-25T17:31:01.132Z","repository":{"id":285072953,"uuid":"956984479","full_name":"huyhvq/google_genai","owner":"huyhvq","description":" Python implementation for interacting with the Google Gemini API.","archived":false,"fork":false,"pushed_at":"2025-03-29T09:46:43.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:28:46.341Z","etag":null,"topics":["api-key-rotation","generative-ai","google-gemini","openwebui-pipe"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huyhvq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-29T09:24:21.000Z","updated_at":"2025-03-29T09:46:46.000Z","dependencies_parsed_at":"2025-03-29T10:38:59.051Z","dependency_job_id":null,"html_url":"https://github.com/huyhvq/google_genai","commit_stats":null,"previous_names":["huyhvq/google_genai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huyhvq/google_genai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huyhvq%2Fgoogle_genai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huyhvq%2Fgoogle_genai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huyhvq%2Fgoogle_genai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huyhvq%2Fgoogle_genai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huyhvq","download_url":"https://codeload.github.com/huyhvq/google_genai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huyhvq%2Fgoogle_genai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28755913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T16:32:25.380Z","status":"ssl_error","status_checked_at":"2026-01-25T16:32:09.189Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-key-rotation","generative-ai","google-gemini","openwebui-pipe"],"created_at":"2026-01-25T17:31:01.049Z","updated_at":"2026-01-25T17:31:01.119Z","avatar_url":"https://github.com/huyhvq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Gemini Pipe\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python Version](https://img.shields.io/badge/Python-%3E=3.7-blue)](https://www.python.org/downloads/)\n\n**OpenWebUI Pipe for Google Gemini with API Key Rotation**\n\nThis project provides a Python pipe designed to seamlessly integrate Google's powerful Gemini models into [OpenWebUI](https://github.com/open-webui/open-webui) or similar platforms. A key feature is its support for **API key rotation**, allowing you to use multiple Google API keys for enhanced reliability, rate limit management, and key security.\n\n**Author:** [huyhvq](https://github.com/huyhvq)\n\n**Repository URL:** [https://github.com/huyhvq/google_genai](https://github.com/huyhvq/google_genai)\n\n## Features\n\n- **Google Gemini Integration:**  Leverages the `google-generativeai` Python SDK to interact with Google's Gemini family of models (Gemini Pro, Gemini Pro Vision, etc.).\n- **API Key Rotation:** Supports providing a comma-separated list of Google API keys via environment variables. The pipe automatically rotates through these keys for each API call, helping to avoid rate limits and improve service availability.\n- **OpenWebUI Compatibility:** Designed to function as a pipe within the OpenWebUI framework, easily adding Google Gemini models to your OpenWebUI instance.\n- **Model Listing:** Automatically retrieves and registers available Google Gemini models that support content generation, making them selectable in OpenWebUI.\n- **Safety Settings:** Includes an option to use permissive safety settings (BLOCK_NONE) via an environment variable, allowing for more flexible content generation (use with caution!).\n- **Detailed Logging (Debug Mode):**  Provides comprehensive logging for debugging and monitoring, which can be enabled or disabled via a `DEBUG` flag in the code.\n- **System Message Handling:**  Correctly processes system messages within conversations to guide the Gemini model's behavior.\n- **Multi-part Content Support:** Handles text and image content within messages, enabling multimodal interactions with Gemini models that support them (like Gemini Pro Vision).\n- **Streaming Support:** (To be implemented/verified - check code comments) Potentially supports streaming responses from Gemini for a more interactive user experience.\n\n## Installation\n\nThis pipe is intended to be used within an OpenWebUI environment.  You will typically place this code within the `pipes` directory of your OpenWebUI installation.\n\n1. **Clone or Download:** Download the `google_genai` directory (or the Python file if it's a single file pipe) into the `pipes` directory of your OpenWebUI instance.\n2. **Dependencies:** Ensure you have the `google-generativeai` Python library installed. You can install it using pip:\n\n   ```bash\n   pip install google-generativeai\n   ```\n\n## Configuration\n\n### Environment Variables\n\nThe Google Gemini Pipe relies on environment variables for configuration:\n\n- **`GOOGLE_API_KEY`:**  **(Required)**  Set this to your Google API key. To use API key rotation, provide a comma-separated list of API keys. For example:\n\n  ```bash\n  export GOOGLE_API_KEY=\"YOUR_API_KEY_1,YOUR_API_KEY_2,YOUR_API_KEY_3\"\n  ```\n\n  If you only have one API key, just set it directly:\n\n  ```bash\n  export GOOGLE_API_KEY=\"YOUR_SINGLE_API_KEY\"\n  ```\n\n- **`USE_PERMISSIVE_SAFETY`:** (Optional) Set this to `\"true\"`, `\"1\"`, or `\"yes\"` to enable permissive safety settings (BLOCK_NONE for all safety categories). This disables Google's safety filters and allows potentially harmful content to be generated. **Use with extreme caution and only if you understand the risks.**  If not set or set to any other value, default Google safety settings will be applied.\n\n  ```bash\n  export USE_PERMISSIVE_SAFETY=\"true\"\n  ```\n\n### Valves (OpenWebUI Configuration)\n\nWithin OpenWebUI's settings, you will find \"Valves\" for each pipe. For the \"Google Gemini Pipe\", you should configure the `GOOGLE_API_KEY` valve. While the environment variable is the primary way to set the API key, the Valves in OpenWebUI can provide another layer of configuration within the UI itself.  Setting the `GOOGLE_API_KEY` environment variable is generally recommended for persistent configuration.\n\n## Usage in OpenWebUI\n\n1. **Start or Restart OpenWebUI:** Ensure your OpenWebUI instance is running or restart it after placing the pipe code in the `pipes` directory and setting the environment variables.\n2. **Select Model:** In the OpenWebUI chat interface, you should now see Google Gemini models listed in the model selection dropdown. The model names will correspond to the display names provided by the Google Gemini API (e.g., \"Gemini Pro\", \"Gemini Pro Vision\").\n3. **Start Chatting:** Select a Google Gemini model and begin your conversation. The pipe will handle communication with the Google Gemini API, API key rotation, and response processing.\n\n## License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for more details (if you have a LICENSE file, otherwise, you might want to create one).\n\n## Disclaimer\n\nThis project is provided as-is, without warranty. Use it at your own risk. Be mindful of Google Gemini API usage and billing. Permissive safety settings should be used with caution and only when appropriate for your use case.\n\n**Enjoy using Google Gemini with API Key Rotation in OpenWebUI!**\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuyhvq%2Fgoogle_genai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuyhvq%2Fgoogle_genai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuyhvq%2Fgoogle_genai/lists"}