|
| 1 | +# Gemini-Free-API |
| 2 | + |
| 3 | +OpenAI-compatible API server for Google Gemini Web - free, no API key required. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Free Gemini Access** - Use Gemini 3.1 Pro and Gemini 3.0 Flash via web interface |
| 8 | +- **OpenAI Compatible** - Works with OpenAI SDK, Claude SDK, and any OpenAI-compatible client |
| 9 | +- **Image Generation** - Generate images with automatic watermark removal |
| 10 | +- **Streaming Support** - Real-time streaming responses |
| 11 | +- **Docker Ready** - One-command deployment with Docker |
| 12 | + |
| 13 | +## Quick Start |
| 14 | + |
| 15 | +### Docker (Recommended) |
| 16 | + |
| 17 | +```bash |
| 18 | +# Pull and run |
| 19 | +docker run -d -p 3897:3897 \ |
| 20 | + -e SECURE_1PSID="your_cookie_here" \ |
| 21 | + -e SECURE_1PSIDTS="your_cookie_ts" \ |
| 22 | + --name gemini-api \ |
| 23 | + ghcr.io/sialabs/free-api-server:latest |
| 24 | +``` |
| 25 | + |
| 26 | +Or use docker-compose: |
| 27 | + |
| 28 | +```yaml |
| 29 | +services: |
| 30 | + gemini-api: |
| 31 | + image: ghcr.io/sialabs/free-api-server:latest |
| 32 | + ports: |
| 33 | + - "3897:3897" |
| 34 | + environment: |
| 35 | + - SECURE_1PSID=${SECURE_1PSID} |
| 36 | + - SECURE_1PSIDTS=${SECURE_1PSIDTS} |
| 37 | +``` |
| 38 | +
|
| 39 | +### Get Cookies |
| 40 | +
|
| 41 | +1. Visit https://gemini.google.com and login |
| 42 | +2. Press F12 → Application → Cookies |
| 43 | +3. Copy `__Secure-1PSID` and `__Secure-1PSIDTS` values |
| 44 | + |
| 45 | +### Usage |
| 46 | + |
| 47 | +```python |
| 48 | +from openai import OpenAI |
| 49 | +
|
| 50 | +client = OpenAI( |
| 51 | + api_key="dummy", |
| 52 | + base_url="http://localhost:3897/v1" |
| 53 | +) |
| 54 | +
|
| 55 | +# Chat |
| 56 | +response = client.chat.completions.create( |
| 57 | + model="gpt-3.5-turbo", |
| 58 | + messages=[{"role": "user", "content": "Hello!"}] |
| 59 | +) |
| 60 | +print(response.choices[0].message.content) |
| 61 | +
|
| 62 | +# Generate Image |
| 63 | +response = client.images.generate( |
| 64 | + model="gemini-3-pro-image", |
| 65 | + prompt="A cute cat" |
| 66 | +) |
| 67 | +print(response.data[0].url) |
| 68 | +``` |
| 69 | + |
| 70 | +## API Endpoints |
| 71 | + |
| 72 | +| Endpoint | Description | |
| 73 | +|----------|-------------| |
| 74 | +| `GET /v1/models` | List available models | |
| 75 | +| `POST /v1/chat/completions` | Chat completion | |
| 76 | +| `POST /v1/images/generations` | Image generation | |
| 77 | +| `GET /docs` | API documentation (Swagger) | |
| 78 | + |
| 79 | +## Environment Variables |
| 80 | + |
| 81 | +| Variable | Required | Description | |
| 82 | +|----------|----------|-------------| |
| 83 | +| `SECURE_1PSID` | Yes | Gemini cookie | |
| 84 | +| `SECURE_1PSIDTS` | Yes | Gemini cookie TS | |
| 85 | +| `PROXY` | No | HTTP proxy URL | |
| 86 | + |
| 87 | +## Model Mapping |
| 88 | + |
| 89 | +| OpenAI Model | Gemini Model | |
| 90 | +|--------------|--------------| |
| 91 | +| gpt-3.5-turbo | gemini-3.0-flash | |
| 92 | +| gpt-4 | gemini-3.1-pro | |
| 93 | +| gemini-3-pro-image | gemini-3.0-flash (auto watermark removal) | |
| 94 | + |
| 95 | +## License |
| 96 | + |
| 97 | +See LICENSE file. |
| 98 | + |
| 99 | +## Credits |
| 100 | + |
| 101 | +- [gemini-webapi](https://github.com/HanaokaYuzu/Gemini-API) - Core library |
0 commit comments