{"id":29099308,"url":"https://github.com/nativu5/gemini-fastapi","last_synced_at":"2026-01-21T13:25:26.815Z","repository":{"id":300255550,"uuid":"1000933836","full_name":"Nativu5/Gemini-FastAPI","owner":"Nativu5","description":"Web-based Gemini models wrapped into an OpenAI-compatible API.","archived":false,"fork":false,"pushed_at":"2025-12-06T09:37:22.000Z","size":185,"stargazers_count":405,"open_issues_count":6,"forks_count":64,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-19T22:56:07.063Z","etag":null,"topics":["fastapi","gemini","openai-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"zhiyu1998/Gemi2Api-Server","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nativu5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-12T14:44:46.000Z","updated_at":"2026-01-19T08:23:05.000Z","dependencies_parsed_at":"2025-07-07T07:34:05.414Z","dependency_job_id":"6276d209-d8ec-4bf4-a704-81f88697ee9d","html_url":"https://github.com/Nativu5/Gemini-FastAPI","commit_stats":null,"previous_names":["nativu5/geminiorbiter","nativu5/gemini-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Nativu5/Gemini-FastAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nativu5%2FGemini-FastAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nativu5%2FGemini-FastAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nativu5%2FGemini-FastAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nativu5%2FGemini-FastAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nativu5","download_url":"https://codeload.github.com/Nativu5/Gemini-FastAPI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nativu5%2FGemini-FastAPI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28633757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["fastapi","gemini","openai-api"],"created_at":"2025-06-28T16:06:58.570Z","updated_at":"2026-01-21T13:25:26.797Z","avatar_url":"https://github.com/Nativu5.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gemini-FastAPI\n\n[![Python 3.12](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.115+-green.svg)](https://fastapi.tiangolo.com/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n[ English | [中文](README.zh.md) ]\n\nWeb-based Gemini models wrapped into an OpenAI-compatible API. Powered by [HanaokaYuzu/Gemini-API](https://github.com/HanaokaYuzu/Gemini-API).\n\n**✅ Call Gemini's web-based models via API without an API Key, completely free!**\n\n## Features\n\n- **🔐 No Google API Key Required**: Use web cookies to freely access Gemini's models via API.\n- **🔍 Google Search Included**: Get up-to-date answers using web-based Gemini's search capabilities.\n- **💾 Conversation Persistence**: LMDB-based storage supporting multi-turn conversations.\n- **🖼️ Multi-modal Support**: Support for handling text, images, and file uploads.\n- **⚖️ Multi-account Load Balancing**: Distribute requests across multiple accounts with per-account proxy settings.\n\n## Quick Start\n\n**For Docker deployment, see the [Docker Deployment](#docker-deployment) section below.**\n\n### Prerequisites\n\n- Python 3.12\n- Google account with Gemini access on web\n- `secure_1psid` and `secure_1psidts` cookies from Gemini web interface\n\n### Installation\n\n#### Using uv (Recommended)\n\n```bash\ngit clone https://github.com/Nativu5/Gemini-FastAPI.git\ncd Gemini-FastAPI\nuv sync\n```\n\n#### Using pip\n\n```bash\ngit clone https://github.com/Nativu5/Gemini-FastAPI.git\ncd Gemini-FastAPI\npip install -e .\n```\n\n### Configuration\n\nEdit `config/config.yaml` and provide at least one credential pair:\n\n```yaml\ngemini:\n  clients:\n    - id: \"client-a\"\n      secure_1psid: \"YOUR_SECURE_1PSID_HERE\"\n      secure_1psidts: \"YOUR_SECURE_1PSIDTS_HERE\"\n      proxy: null # Optional proxy URL (null/empty keeps direct connection)\n```\n\n\u003e [!NOTE]\n\u003e For details, refer to the [Configuration](#configuration-1) section below.\n\n### Running the Server\n\n```bash\n# Using uv\nuv run python run.py\n\n# Using Python directly\npython run.py\n```\n\nThe server will start on `http://localhost:8000` by default.\n\n## Docker Deployment\n\n### Run with Options\n\n```bash\ndocker run -p 8000:8000 \\\n  -v $(pwd)/data:/app/data \\\n  -v $(pwd)/cache:/app/cache \\\n  -e CONFIG_SERVER__API_KEY=\"your-api-key-here\" \\\n  -e CONFIG_GEMINI__CLIENTS__0__ID=\"client-a\" \\\n  -e CONFIG_GEMINI__CLIENTS__0__SECURE_1PSID=\"your-secure-1psid\" \\\n  -e CONFIG_GEMINI__CLIENTS__0__SECURE_1PSIDTS=\"your-secure-1psidts\" \\\n  -e GEMINI_COOKIE_PATH=\"/app/cache\" \\\n  ghcr.io/nativu5/gemini-fastapi\n```\n\n\u003e [!TIP]\n\u003e Add `CONFIG_GEMINI__CLIENTS__N__PROXY` only if you need a proxy; omit the variable to keep direct connections.\n\u003e\n\u003e `GEMINI_COOKIE_PATH` points to the directory inside the container where refreshed cookies are stored. Bind-mounting it (e.g. `-v $(pwd)/cache:/app/cache`) preserves those cookies across container rebuilds/recreations so you rarely need to re-authenticate.\n\n### Run with Docker Compose\n\nCreate a `docker-compose.yml` file:\n\n```yaml\nservices:\n  gemini-fastapi:\n    image: ghcr.io/nativu5/gemini-fastapi:latest\n    ports:\n      - \"8000:8000\"\n    volumes:\n      # - ./config:/app/config      # Uncomment to use a custom config file\n      # - ./certs:/app/certs        # Uncomment to enable HTTPS with your certs\n      - ./data:/app/data\n      - ./cache:/app/cache\n    environment:\n      - CONFIG_SERVER__HOST=0.0.0.0\n      - CONFIG_SERVER__PORT=8000\n      - CONFIG_SERVER__API_KEY=${API_KEY}\n      - CONFIG_GEMINI__CLIENTS__0__ID=client-a\n      - CONFIG_GEMINI__CLIENTS__0__SECURE_1PSID=${SECURE_1PSID}\n      - CONFIG_GEMINI__CLIENTS__0__SECURE_1PSIDTS=${SECURE_1PSIDTS}\n      - GEMINI_COOKIE_PATH=/app/cache # must match the cache volume mount above\n    restart: on-failure:3             # Avoid retrying too many times\n```\n\nThen run:\n\n```bash\ndocker compose up -d\n```\n\n\u003e [!IMPORTANT]\n\u003e Make sure to mount the `/app/data` volume to persist conversation data between container restarts.\n\u003e Also mount `/app/cache` so refreshed cookies (including rotated 1PSIDTS values) survive container rebuilds/recreates without re-auth.\n\n## Configuration\n\nThe server reads a YAML configuration file located at `config/config.yaml`.\n\nFor details on each configuration option, refer to the comments in the [`config/config.yaml`](https://github.com/Nativu5/Gemini-FastAPI/blob/main/config/config.yaml) file.\n\n### Environment Variable Overrides\n\n\u003e [!TIP]\n\u003e This feature is particularly useful for Docker deployments and production environments where you want to keep sensitive credentials separate from configuration files.\n\nYou can override any configuration option using environment variables with the `CONFIG_` prefix. Use double underscores (`__`) to represent nested keys, for example:\n\n```bash\n# Override server settings\nexport CONFIG_SERVER__API_KEY=\"your-secure-api-key\"\n\n# Override Gemini credentials for client 0\nexport CONFIG_GEMINI__CLIENTS__0__ID=\"client-a\"\nexport CONFIG_GEMINI__CLIENTS__0__SECURE_1PSID=\"your-secure-1psid\"\nexport CONFIG_GEMINI__CLIENTS__0__SECURE_1PSIDTS=\"your-secure-1psidts\"\n\n# Override optional proxy settings for client 0\nexport CONFIG_GEMINI__CLIENTS__0__PROXY=\"socks5://127.0.0.1:1080\"\n\n# Override conversation storage size limit\nexport CONFIG_STORAGE__MAX_SIZE=268435456  # 256 MB\n```\n\n### Client IDs and Conversation Reuse\n\nConversations are stored with the ID of the client that generated them.\nKeep these identifiers stable in your configuration so that sessions remain valid\nwhen you update the cookie list.\n\n### Gemini Credentials\n\n\u003e [!WARNING]\n\u003e Keep these credentials secure and never commit them to version control. These cookies provide access to your Google account.\n\nTo use Gemini-FastAPI, you need to extract your Gemini session cookies:\n\n1. Open [Gemini](https://gemini.google.com/) in a private/incognito browser window and sign in\n2. Open Developer Tools (F12)\n3. Navigate to **Application** → **Storage** → **Cookies**\n4. Find and copy the values for:\n   - `__Secure-1PSID`\n   - `__Secure-1PSIDTS`\n\n\u003e [!TIP]\n\u003e For detailed instructions, refer to the [HanaokaYuzu/Gemini-API authentication guide](https://github.com/HanaokaYuzu/Gemini-API?tab=readme-ov-file#authentication).\n\n### Proxy Settings\n\nEach client entry can be configured with a different proxy to work around rate limits. Omit the `proxy` field or set it to `null` or an empty string to keep a direct connection.\n\n## Acknowledgments\n\n- [HanaokaYuzu/Gemini-API](https://github.com/HanaokaYuzu/Gemini-API) - The underlying Gemini web API client\n- [zhiyu1998/Gemi2Api-Server](https://github.com/zhiyu1998/Gemi2Api-Server) - This project originated from this repository. After extensive refactoring and engineering improvements, it has evolved into an independent project, featuring multi-turn conversation reuse among other enhancements. Special thanks for the inspiration and foundational work provided.\n\n## Disclaimer\n\nThis project is not affiliated with Google or OpenAI and is intended solely for educational and research purposes. It uses reverse-engineered APIs and may not comply with Google's Terms of Service. Use at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativu5%2Fgemini-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnativu5%2Fgemini-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativu5%2Fgemini-fastapi/lists"}