Skip to content

Gemini-based translation API that integrates with the "Immersive Translate", 基于 Gemini 的翻译 API,可与沉浸式翻译插件集成

Notifications You must be signed in to change notification settings

MUTED64/GeminiTranslate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GeminiTranslate: Free Python Translation API using Google Gemini

中文版本文档

This is a translation API written in Python that integrates with "immersive translation" plugin in browser, using the Google Gemini API, which is powered by Google's generative AI technology.

Usage

To use the GeminiTranslate, follow the steps below:

  1. Obtain a free API key from Google. You can configure the API key by replacing os.getenv('GOOGLE_API_KEY') with your actual API key in main.py:

    genai.configure(api_key="YOUR_API_KEY")
  2. Install the required dependencies:

     pip install -r requirements.txt
  3. Run the Flask application on the local server, default API address is http://127.0.0.1/translate:

    python ./main.py
  4. Configure immersive translation plugin.

    • In developer settings, turn on Beta features.
    • Basic settings -> Translate service -> Custom API
    • Set API URL to your API address, default is http://127.0.0.1/translate.
  5. Enjoy!

Notes

  • You can adjust the safety_settings and generation_config parameters according to your requirements, default is none.
  • Make sure you can access the Google API, otherwise you may need to use a proxy.
  • The API is limited to 60 times per minute, you can apply for a higher limit here, or set the maximum number of requests per second to 1 in the immersive translation custom options.
  • Prompt injection may exist in the translation result.
  • Gemini API is not allow to talk about OpenAI😑
  • Recommended to use the maximum number of requests per second in the custom options: 1, the maximum number of paragraphs per request: 20, to avoid exceeding the limit.

About

Gemini-based translation API that integrates with the "Immersive Translate", 基于 Gemini 的翻译 API,可与沉浸式翻译插件集成

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages