GeminiTranslate
GeminiTranslate copied to clipboard
Gemini-based translation API that integrates with the "Immersive Translate", 基于 Gemini 的翻译 API,可与沉浸式翻译插件集成
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:
-
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 inmain.py:genai.configure(api_key="YOUR_API_KEY") -
Install the required dependencies:
pip install -r requirements.txt -
Run the Flask application on the local server, default API address is
http://127.0.0.1/translate:python ./main.py -
Configure immersive translation plugin.
- In developer settings, turn on
Beta features. - Basic settings -> Translate service -> Custom API
- Set
API URLto your API address, default ishttp://127.0.0.1/translate.
- In developer settings, turn on
-
Enjoy!
Notes
- You can adjust the
safety_settingsandgeneration_configparameters 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.