Gemini REST API System

Tech stack:
PY
HTML
CSS
JS

Easily expandable system, takes in prompt and responds in JSON or text. Can easily set AI Model and API keys via environment variables.
AI Contributions:0
Published At:October 22, 2026
Files Included:0 file(s)

Read Me

# Gemini REST API System


A small Flask application that accepts a prompt, sends it to the Gemini REST API, and displays the answer as regular text or JSON.


## Requirements


- Python 3.10+
- A Gemini API key from [Google AI Studio](https://aistudio.google.com/apikey)


## Run locally


1. Create a local environment file and add your key:


   ```powershell
   Copy-Item .env.example .env
   ```


   Set `GEMINI_API_KEY` in `.env`.
2. Install dependencies and start the app:


   ```powershell
   python -m venv .venv
   .\.venv\Scripts\Activate.ps1
   python -m pip install -r requirements.txt
   python -m flask --app wsgi:application run
   ```
3. Open <http://127.0.0.1:5000>.


For a production-style local server, use `python -m gunicorn -c gunicorn.conf.py wsgi:application` on systems where Gunicorn is supported. The included `Procfile` uses the same command.


## API


`POST /api/generate` accepts a JSON object:


```json
{
  "prompt": "Summarize the water cycle in three sentences.",
  "response_format": "text"
}
```


Set `response_format` to `text` or `json`. It defaults to `text`. The JSON option asks Gemini for JSON output and returns the decoded JSON value.


Successful response:


```json
{
  "response_format": "text",
  "response": "Water evaporates from Earth's surface..."
}
```


Errors return a JSON `error` message and an appropriate HTTP status. `GET /api/health` reports service status and whether a Gemini key is configured.


## Configuration


See [.env.example](./.env.example). `GEMINI_API_KEY` is required and must remain server-side. `GEMINI_MODEL`, `GEMINI_TIMEOUT_SECONDS`, and `GEMINI_MAX_RETRIES` optionally configure Gemini requests. `PORT` and `GUNICORN_TIMEOUT` configure the web server.


## Tests


```powershell
python -m pytest
```


## License


MIT. See [LICENSE](./LICENSE).

Loading

Loading

Loading

More like this View all

Supabase Login and Signup System with MFA

A fully completed system integrated with Supabase Authentication along with authenticator app and basic interface fully work. Set environment variables for MFA system controls and Supabae API config.

  • 0

    Ratings

  • 27

    Files

    • PY
    • HTML
    • +4

    Tech stack

psxdata-feed

This repo showcases the use of the psxdata Python package to extract stock market information for companies listed on the Pakistan Stock Exchange. You can monitor selected companies and analyze them.

  • 0

    Ratings

  • 15

    Files

    • JS
    • PY
    • +3

    Tech stack

Deep-web-academic-search

Deep-web-academic-search

  • 0

    Ratings

  • 16

    Files

    • JS
    • HTML
    • +2

    Tech stack