{"id":46035298,"url":"https://github.com/ntthanh2603/gemini-web-to-api","last_synced_at":"2026-05-07T04:02:51.377Z","repository":{"id":331446243,"uuid":"1125622690","full_name":"ntthanh2603/gemini-web-to-api","owner":"ntthanh2603","description":"✨Reverse-engineered API for Gemini web app. It can be used as a genuine API key from OpenAI, Gemini, and Claude.","archived":false,"fork":false,"pushed_at":"2026-02-24T23:43:38.000Z","size":84502,"stargazers_count":24,"open_issues_count":0,"forks_count":13,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-25T04:49:20.221Z","etag":null,"topics":["ai","api","chatbot","claude","docker","fiber-framework","gemini","gemini-api","generative-ai","google","llm","openai","proxy-server","rest-api","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntthanh2603.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-12-31T04:01:00.000Z","updated_at":"2026-02-24T23:43:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ntthanh2603/gemini-web-to-api","commit_stats":null,"previous_names":["ntthanh2603/ai-bridges","ntthanh2603/gemini-web-to-api"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/ntthanh2603/gemini-web-to-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntthanh2603%2Fgemini-web-to-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntthanh2603%2Fgemini-web-to-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntthanh2603%2Fgemini-web-to-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntthanh2603%2Fgemini-web-to-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntthanh2603","download_url":"https://codeload.github.com/ntthanh2603/gemini-web-to-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntthanh2603%2Fgemini-web-to-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ai","api","chatbot","claude","docker","fiber-framework","gemini","gemini-api","generative-ai","google","llm","openai","proxy-server","rest-api","reverse-proxy"],"created_at":"2026-03-01T05:16:20.048Z","updated_at":"2026-05-07T04:02:51.364Z","avatar_url":"https://github.com/ntthanh2603.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/gemini.png\" width=\"400\" alt=\"Gemini Logo\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/ntthanh2603/gemini-web-to-api/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/ntthanh2603/gemini-web-to-api?style=flat-square\u0026logo=github\u0026color=3670ad\" alt=\"Release\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://golang.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Go-1.21+-00ADD8?style=flat-square\u0026logo=go\" alt=\"Go Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.docker.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Docker-Ready-2496ED?style=flat-square\u0026logo=docker\" alt=\"Docker\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ntthanh2603/gemini-web-to-api/pkgs/container/gemini-web-to-api\"\u003e\u003cimg src=\"https://img.shields.io/badge/GHCR-Ready-2496ED?style=flat-square\u0026logo=github\" alt=\"GHCR\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ntthanh2603/gemini-web-to-api/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/ntthanh2603/gemini-web-to-api?style=flat-square\u0026color=orange\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=flat-square\" alt=\"Maintained\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/ntthanh2603/gemini-web-to-api/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/ntthanh2603/gemini-web-to-api?style=flat-square\u0026color=gold\u0026label=stars\" alt=\"Stars\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/ntthanh2603/gemini-web-to-api/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/ntthanh2603/gemini-web-to-api?style=flat-square\u0026color=red\u0026label=issues\" alt=\"Issues\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\" alt=\"PRs Welcome\"\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eGemini Web To API 🚀\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  Transforms Google Gemini web interface into a standardized REST API.\u003cbr/\u003e\n  Access Gemini's power without API keys — just use your cookies!\n\u003c/p\u003e\n\n\u003e [!NOTE]\n\u003e This project is intended for **research and educational purposes only**. Please use responsibly and refrain from any commercial use.\n\n\u003e [!WARNING]\n\u003e This project is not affiliated with Google. It uses reverse-engineered web cookies and may not comply with [Google's Terms of Service](https://policies.google.com/terms). Use at your own risk — the author assumes no responsibility for any account actions or data loss.\n\n---\n\n## 🎯 Why Gemini Web To API?\n\n**Problem**: You want to use Google Gemini's latest models, but you don't have an API key or prefer not to use one.\n\n**Solution**: Creates a local API server that:\n\n- ✅ Connects to Gemini's web interface using your browser cookies\n- ✅ Exposes OpenAI / Claude / Gemini-compatible API endpoints\n- ✅ No API keys needed — just cookies from your browser\n- ✅ Handles authentication and session management automatically\n\n**Use Cases**:\n\n- Use Gemini without API keys\n- Test Gemini integration locally\n- Build applications leveraging Gemini's latest models\n- Develop with cookie-based authentication\n\n---\n\n## ⚡ Quick Start\n\n### 🐳 Option A — Docker Run (no setup required)\n\n\u003e No cloning needed — pull and run directly from the registry.\n\n**Step 1 — Get your cookies**\n\n\u003e [!WARNING]\n\u003e Keep these values secure and **never share or commit them** — they provide direct access to your Google account.\n\n1. Go to [gemini.google.com](https://gemini.google.com) and sign in\n2. Press `F12` → **Application** → **Storage** → **Cookies**\n3. Copy the values of `__Secure-1PSID` and `__Secure-1PSIDTS`\n\n**Step 2 — Run**\n\n```bash\ndocker run -d -p 4981:4981 \\\n  -e GEMINI_1PSID=\"your_psid_here\" \\\n  -e GEMINI_1PSIDTS=\"your_psidts_here\" \\\n  -e GEMINI_REFRESH_INTERVAL=30 \\\n  -e GEMINI_MAX_RETRIES=3 \\\n  -e APP_ENV=production \\\n  -e RATE_LIMIT_ENABLED=true \\\n  -e RATE_LIMIT_WINDOW_MS=60000 \\\n  -e RATE_LIMIT_MAX_REQUESTS=10 \\\n  -v ./cookies:/home/appuser/.cookies \\\n  --tmpfs /tmp:rw,size=512m \\\n  --tmpfs /home/appuser/.cache:rw,size=256m \\\n  --name gemini-web-to-api \\\n  --restart unless-stopped \\\n  ghcr.io/ntthanh2603/gemini-web-to-api:latest\n```\n\n**Done!** Jump to [Test it](#-test-it). 🎉\n\n---\n\n### 🛠️ Option B — Build from source\n\n\u003e Use this if you want to build for a specific architecture (amd64, arm64, etc.) or modify the source code.\n\n**Step 1 — Clone the repository**\n\n```bash\ngit clone https://github.com/ntthanh2603/gemini-web-to-api.git\ncd gemini-web-to-api\n```\n\n**Step 2 — Get your cookies and configure `.env`**\n\n\u003e [!WARNING]\n\u003e Keep these values secure and **never commit your `.env` file** — it contains credentials that provide access to your Google account.\n\n1. Go to [gemini.google.com](https://gemini.google.com) and sign in\n2. Press `F12` → **Application** → **Storage** → **Cookies**\n3. Copy the values of `__Secure-1PSID` and `__Secure-1PSIDTS`\n4. Create your `.env` from the example:\n\n   ```bash\n   cp .env.example .env\n   ```\n\n5. Paste your cookie values into `.env`:\n\n   ```env\n   GEMINI_1PSID=your_psid_here\n   GEMINI_1PSIDTS=your_psidts_here\n   GEMINI_REFRESH_INTERVAL=30\n   GEMINI_MAX_RETRIES=3\n   APP_ENV=production\n   RATE_LIMIT_ENABLED=true\n   RATE_LIMIT_WINDOW_MS=60000\n   RATE_LIMIT_MAX_REQUESTS=10\n   ```\n\n**Step 3 — Run**\n\nPick whichever method suits your setup:\n\n| Method | Command | Requirements |\n|---|---|---|\n| 🐳 Docker Compose | `docker compose up -d --build` | Docker |\n| 🐹 Go direct | `go run cmd/server/main.go` | [Go 1.21+](https://golang.org/dl/) |\n| ⚡ Task (dev mode) | `task dev` | [Task](https://taskfile.dev) |\n\n**Done!** Jump to [Test it](#-test-it). 🎉\n\n---\n\n### ✅ Test it\n\n```bash\ncurl -X POST http://localhost:4981/openai/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\": \"gemini-advanced\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]}'\n```\n\nYour Gemini Web To API is running at `http://localhost:4981` 🎉\n\n---\n\n## ✨ Features\n\n- 🌉 **Universal AI Bridge**: One server, three protocols (OpenAI, Claude, Gemini)\n- 🔌 **Drop-in Replacement**: Works with existing OpenAI / Claude / Gemini SDKs\n- 🔄 **Smart Session Management**: Auto-rotates cookies to keep sessions alive\n- ⚡ **High Performance**: Built with Go and Fiber for speed\n- 🐳 **Production Ready**: Docker Compose support, Swagger UI, health checks\n- 📝 **Well Documented**: Interactive API docs at `/swagger/`\n\n---\n\n## 🛠️ Configuration\n\n### Environment Variables\n\n| Variable                  | Required | Default | Description                                          |\n| ------------------------- | -------- | ------- | ---------------------------------------------------- |\n| `GEMINI_1PSID`            | ✅ Yes   | —       | Main session cookie from Gemini                      |\n| `GEMINI_1PSIDTS`          | ✅ Yes   | —       | Timestamp cookie (prevents auth errors)              |\n| `GEMINI_REFRESH_INTERVAL` | ❌ No    | `30`    | Cookie rotation interval (minutes)                   |\n| `GEMINI_MAX_RETRIES`      | ❌ No    | `3`     | Max retry attempts when an API call fails            |\n| `PORT`                    | ❌ No    | `4981`  | Server port                                          |\n| `RATE_LIMIT_ENABLED`      | ❌ No    | `false` | Enable or disable rate limiting                      |\n| `RATE_LIMIT_WINDOW_MS`    | ❌ No    | `60000` | Rate limit time window in milliseconds               |\n| `RATE_LIMIT_MAX_REQUESTS` | ❌ No    | `10`    | Maximum number of requests allowed per time window   |\n\n### Configuration Priority\n\n1. **Environment Variables** (highest priority)\n2. **`.env` file**\n3. **Defaults** (lowest priority)\n\n---\n\n## 🧪 Usage Examples\n\n### OpenAI SDK (Python)\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http://localhost:4981/openai/v1\",\n    api_key=\"not-needed\"\n)\n\nresponse = client.chat.completions.create(\n    model=\"gemini-advanced\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\nprint(response.choices[0].message.content)\n```\n\n### Claude SDK (Python)\n\n```python\nfrom langchain_anthropic import ChatAnthropic\n\nllm = ChatAnthropic(\n    base_url=\"http://localhost:4981/claude\",\n    model=\"gemini-advanced\",\n    api_key=\"not-needed\"\n)\n\nresponse = llm.invoke(\"Explain quantum computing\")\nprint(response.content)\n```\n\n### Gemini Native SDK (Python)\n\n```python\nimport google.generativeai as genai\n\ngenai.configure(\n    api_key=\"not-needed\",\n    transport=\"rest\",\n    client_options={\"api_endpoint\": \"http://localhost:4981/gemini\"}\n)\n\nmodel = genai.GenerativeModel(\"gemini-advanced\")\nresponse = model.generate_content(\"Write a poem about coding\")\nprint(response.text)\n```\n\n### cURL\n\n```bash\ncurl -X POST http://localhost:4981/openai/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gemini-advanced\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"What is AI?\"}],\n    \"stream\": false\n  }'\n```\n\nMore examples are available in the [`examples/`](examples/) directory.\n\n---\n\n## 📘 API Documentation\n\nOnce running, visit **`http://localhost:4981/swagger/index.html`** for interactive API documentation.\n\n![Swagger UI](assets/swagger.png)\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.\n\n---\n\n## ⭐ Star History\n\nIf you find this project useful, please consider giving it a star! ⭐\n\n---\n\n## 🔗 Links\n\n- **GitHub**: [ntthanh2603/gemini-web-to-api](https://github.com/ntthanh2603/gemini-web-to-api)\n- **Gemini Web**: [gemini.google.com](https://gemini.google.com)\n- **Issues**: [Report a bug](https://github.com/ntthanh2603/gemini-web-to-api/issues)\n\n---\n\n**Made with ❤️ by the Gemini Web To API team**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntthanh2603%2Fgemini-web-to-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntthanh2603%2Fgemini-web-to-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntthanh2603%2Fgemini-web-to-api/lists"}