Sign inSign up

lolcatcodes/gemini-translate

By lolcatcodes

•Updated 12 months ago

Gemini Translate App - Flask-based Chatbot Translator API

Image
API management
Machine learning & AI
Web servers
0

658

lolcatcodes/gemini-translate repository overview

⁠Gemini Translate App

This is a lightweight Python Flask application that runs an HTTP server with a REST endpoint exposed. This endpoint allows you to request translations for any text in any language.

⁠Key Features:

  • Flask REST Server: Runs a lightweight REST API on a customizable port (default: 8080).
  • Gemini Chatbot Integration: Allows users to send prompts to the Gemini chatbot (gemini-1.5-flash) and get text translated from any language to any language.

⁠How to Run the Image

To run the Docker image, use the following command:

docker run -e GEMINI_API_KEYS=your_gemini_api_key_1,your_gemini_api_key2 -p 8080:8080 lolcatcodes/gemini-translate:latest
  • Port: By default, the application runs on port 8080. If you want to use a different port, map it using the -p flag.
  • Environment Variable: The GEMINI_API_KEYS is required for the application to run. List of keys can be provided separated by comma.

⁠How to Use the Translation API

The app exposes a REST API at the /translate endpoint. You can send a POST request to this endpoint with the following parameters:

⁠Sample POST Request:

Endpoint:

http://localhost:8080/translate⁠

⁠Sample usage example:

curl -X POST http://localhost:8080/translate \
-H "Content-Type: application/json" \
-d '{
  "fromLanguage": "polish",
  "toLanguage": "english",
  "text": "Nie ma co płakać. Trzeba wziąć się w garść!"
}'

Sample Request Body:

{
  "fromLanguage": "polish",
  "toLanguage":  "english",
  "text": "Nie ma co płakać. Trzeba wziąć się w garść!"
}

Sample Response:

{
    "translation": "There is nothing to cry about. You need to pull yourself together!"
}

⁠Environment Variable:

  • GEMINI_API_KEYS: You must define the GEMINI_API_KEYS environment variable with your API key(s) to interact with the Gemini API.

⁠Easy Way to Obtain Your Gemini API Key:

⁠Step 1: Visit the Google AI Studio
  • You can find the landing page here⁠. Once there, click on the “Gemini API” tab or the “Learn more about the Gemini API” button.

  • Alternatively, you can visit the Gemini API landing page directly by clicking here⁠.

⁠Step 2: Click on “Get API Key in Google AI Studio”
  • Follow the instructions on the page to navigate to the API key section.
⁠Step 3: Create Your API Key
  • Click the “Create API Key” button to generate your key. Save this key securely, as it will be required for application usage.

Tag summary

Content type

Image

Digest

sha256:2714016ec…

Size

104.9 MB

Last updated

12 months ago

docker pull lolcatcodes/gemini-translate