{"id":13642486,"url":"https://github.com/amm1rr/webai-to-api","last_synced_at":"2026-05-07T23:48:02.910Z","repository":{"id":183117809,"uuid":"669611694","full_name":"Amm1rr/WebAI-to-API","owner":"Amm1rr","description":"Gemini to API (Don't need API KEY) (ChatGPT, Claude, DeeepSeek, Grok and more)","archived":false,"fork":false,"pushed_at":"2026-05-01T23:17:57.000Z","size":3371,"stargazers_count":1058,"open_issues_count":17,"forks_count":193,"subscribers_count":11,"default_branch":"master","last_synced_at":"2026-05-02T00:31:50.728Z","etag":null,"topics":["ai","api","api-less","bard","chatbot","chatgpt","claude","deepseek","fastapi","free","gemini","gemini-api","google-bard-api","grok","llm","python","uvicorn","webserver","webservice"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Amm1rr.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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":"2023-07-22T21:06:30.000Z","updated_at":"2026-05-01T23:18:01.000Z","dependencies_parsed_at":"2023-12-09T02:30:23.119Z","dependency_job_id":"94e5b53e-8aab-42d8-8aee-bd091a890c9c","html_url":"https://github.com/Amm1rr/WebAI-to-API","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":0.06034482758620685,"last_synced_commit":"0fbb47a534681aee86b93a2373e05f5aac8d3209"},"previous_names":["amm1rr/ai-assistant-api","amm1rr/free-chatbot-api","amm1rr/webai-to-api"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/Amm1rr/WebAI-to-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amm1rr%2FWebAI-to-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amm1rr%2FWebAI-to-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amm1rr%2FWebAI-to-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amm1rr%2FWebAI-to-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Amm1rr","download_url":"https://codeload.github.com/Amm1rr/WebAI-to-API/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Amm1rr%2FWebAI-to-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32760961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["ai","api","api-less","bard","chatbot","chatgpt","claude","deepseek","fastapi","free","gemini","gemini-api","google-bard-api","grok","llm","python","uvicorn","webserver","webservice"],"created_at":"2024-08-02T01:01:32.044Z","updated_at":"2026-05-07T23:48:02.905Z","avatar_url":"https://github.com/Amm1rr.png","language":"Python","funding_links":[],"categories":["Chatbots"],"sub_categories":[],"readme":"## Disclaimer\n\n\u003e **This project is intended for research and educational purposes only.**  \n\u003e Please refrain from any commercial use and act responsibly when deploying or modifying this tool.\n\n---\n\n# WebAI-to-API\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/Server-Run-WebAI.png\" alt=\"WebAI-to-API Server\" height=\"160\" /\u003e\n  \u003cimg src=\"./assets/Server-Run-G4F.png\" alt=\"gpt4free Server\" height=\"160\" /\u003e\n\u003c/p\u003e\n\n**WebAI-to-API** is a modular web server built with FastAPI that allows you to expose your preferred browser-based LLM (such as Gemini) as a local API endpoint.\n\n---\n\nThis project supports **two operational modes**:\n\n1. **Primary Web Server**\n\n   \u003e WebAI-to-API\n\n   Connects to the Gemini web interface using your browser cookies and exposes it as an API endpoint. This method is lightweight, fast, and efficient for personal use.\n\n2. **Fallback Web Server (gpt4free)**\n\n   \u003e [gpt4free](https://github.com/xtekky/gpt4free)\n\n   A secondary server powered by the `gpt4free` library, offering broader access to multiple LLMs beyond Gemini, including:\n\n   - ChatGPT\n   - Claude\n   - DeepSeek\n   - Copilot\n   - HuggingFace Inference\n   - Grok\n   - ...and many more.\n\nThis design provides both **speed and redundancy**, ensuring flexibility depending on your use case and available resources.\n\n---\n\n## Features\n\n- 🌐 **Available Endpoints**:\n\n  - **WebAI Server**:\n\n    - `/v1/chat/completions`\n    - `/gemini`\n    - `/gemini-chat`\n    - `/translate`\n    - `/v1beta/models/{model}` (Google Generative AI v1beta API)\n\n  - **gpt4free Server**:\n    - `/v1`\n    - `/v1/chat/completions`\n\n- 🔄 **Server Switching**: Easily switch between servers in terminal.\n\n- 🛠️ **Modular Architecture**: Organized into clearly defined modules for API routes, services, configurations, and utilities, making development and maintenance straightforward.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/Endpoints-Docs.png\" alt=\"Endpoints\" height=\"280\" /\u003e\n\u003c/p\u003e\n\n---\n\n## Installation\n\n1. **Clone the repository:**\n\n   ```bash\n   git clone https://github.com/Amm1rr/WebAI-to-API.git\n   cd WebAI-to-API\n   ```\n\n2. **Install dependencies using Poetry:**\n\n   ```bash\n   poetry install\n   ```\n\n3. **Create and update the configuration file:**\n\n   ```bash\n   cp config.conf.example config.conf\n   ```\n\n   Then, edit `config.conf` to adjust service settings and other options.\n\n4. **Run the server:**\n\n   ```bash\n   poetry run python src/run.py\n   ```\n\n---\n\n## Usage\n\nSend a POST request to `/v1/chat/completions` (or any other available endpoint) with the required payload.\n\n### Supported Models\n\n| Model                       | Description                        |\n| --------------------------- | ---------------------------------- |\n| `gemini-3.0-pro`            | Most powerful model                |\n| `gemini-3.0-flash`          | Fast and efficient model (default) |\n| `gemini-3.0-flash-thinking` | Enhanced reasoning model           |\n\n### Example Request (Basic)\n\n```json\n{\n  \"model\": \"gemini-3.0-pro\",\n  \"messages\": [{ \"role\": \"user\", \"content\": \"Hello!\" }]\n}\n```\n\n### Example Request (With System Prompt \u0026 Conversation History)\n\n```json\n{\n  \"model\": \"gemini-3.0-flash-thinking\",\n  \"messages\": [\n    { \"role\": \"system\", \"content\": \"You are a helpful assistant.\" },\n    { \"role\": \"user\", \"content\": \"What is Python?\" },\n    { \"role\": \"assistant\", \"content\": \"Python is a programming language.\" },\n    { \"role\": \"user\", \"content\": \"Is it easy to learn?\" }\n  ]\n}\n```\n\n### Example Response\n\n```json\n{\n  \"id\": \"chatcmpl-12345\",\n  \"object\": \"chat.completion\",\n  \"created\": 1693417200,\n  \"model\": \"gemini-3.0-pro\",\n  \"choices\": [\n    {\n      \"message\": {\n        \"role\": \"assistant\",\n        \"content\": \"Hi there!\"\n      },\n      \"finish_reason\": \"stop\",\n      \"index\": 0\n    }\n  ],\n  \"usage\": {\n    \"prompt_tokens\": 0,\n    \"completion_tokens\": 0,\n    \"total_tokens\": 0\n  }\n}\n```\n\n---\n\n## Documentation\n\n### WebAI-to-API Endpoints\n\n\u003e `POST /gemini`\n\nInitiates a new conversation with the LLM. Each request creates a **fresh session**, making it suitable for stateless interactions.\n\n\u003e `POST /gemini-chat`\n\nContinues a persistent conversation with the LLM without starting a new session. Ideal for use cases that require context retention between messages.\n\n\u003e `POST /translate`\n\nDesigned for quick integration with the [Translate It!](https://github.com/iSegaro/Translate-It) browser extension.\nFunctionally identical to `/gemini-chat`, meaning it **maintains session context** across requests.\n\n\u003e `POST /v1/chat/completions`\n\n**OpenAI-compatible endpoint** with full support for:\n- **System prompts**: Set behavior and context for the assistant\n- **Conversation history**: Maintain context across multiple turns (user/assistant messages)\n- **Streaming**: Optional streaming response support\n\nBuilt for seamless integration with clients that expect the OpenAI API format.\n\n\u003e `POST /v1beta/models/{model}`\n\n**Google Generative AI v1beta API** compatible endpoint.\nProvides access to the latest Google Generative AI models with standard Google API format including safety ratings and structured responses.\n\n---\n\n### gpt4free Endpoints\n\nThese endpoints follow the **OpenAI-compatible structure** and are powered by the `gpt4free` library.  \nFor detailed usage and advanced customization, refer to the official documentation:\n\n- 📄 [Provider Documentation](https://github.com/gpt4free/g4f.dev/blob/main/docs/selecting_a_provider.md)\n- 📄 [Model Documentation](https://github.com/gpt4free/g4f.dev/blob/main/docs/providers-and-models.md)\n\n#### Available Endpoints (gpt4free API Layer)\n\n```\nGET  /                              # Health check\nGET  /v1                            # Version info\nGET  /v1/models                     # List all available models\nGET  /api/{provider}/models         # List models from a specific provider\nGET  /v1/models/{model_name}        # Get details of a specific model\n\nPOST /v1/chat/completions           # Chat with default configuration\nPOST /api/{provider}/chat/completions\nPOST /api/{provider}/{conversation_id}/chat/completions\n\nPOST /v1/responses                  # General response endpoint\nPOST /api/{provider}/responses\n\nPOST /api/{provider}/images/generations\nPOST /v1/images/generations\nPOST /v1/images/generate            # Generate images using selected provider\n\nPOST /v1/media/generate             # Media generation (audio/video/etc.)\n\nGET  /v1/providers                  # List all providers\nGET  /v1/providers/{provider}       # Get specific provider info\n\nPOST /api/{path_provider}/audio/transcriptions\nPOST /v1/audio/transcriptions       # Audio-to-text\n\nPOST /api/markitdown                # Markdown rendering\n\nPOST /api/{path_provider}/audio/speech\nPOST /v1/audio/speech               # Text-to-speech\n\nPOST /v1/upload_cookies             # Upload session cookies (browser-based auth)\n\nGET  /v1/files/{bucket_id}          # Get uploaded file from bucket\nPOST /v1/files/{bucket_id}          # Upload file to bucket\n\nGET  /v1/synthesize/{provider}      # Audio synthesis\n\nPOST /json/{filename}               # Submit structured JSON data\n\nGET  /media/{filename}              # Retrieve media\nGET  /images/{filename}             # Retrieve images\n```\n\n---\n\n## Roadmap\n\n- ✅ Maintenance\n\n---\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003ch2\u003eConfiguration ⚙️\u003c/h2\u003e\n  \u003c/summary\u003e\n\n### Key Configuration Options\n\n| Section     | Option     | Description                                | Example Value           |\n| ----------- | ---------- | ------------------------------------------ | ----------------------- |\n| [AI]        | default_ai | Default service for `/v1/chat/completions` | `gemini`                |\n| [Browser]   | name       | Browser for cookie-based authentication    | `firefox`               |\n| [EnabledAI] | gemini     | Enable/disable Gemini service              | `true`                  |\n| [Proxy]     | http_proxy | Proxy for Gemini connections (optional)    | `http://127.0.0.1:2334` |\n\nThe complete configuration template is available in [`WebAI-to-API/config.conf.example`](WebAI-to-API/config.conf.example).  \nIf the cookies are left empty, the application will automatically retrieve them using the default browser specified.\n\n---\n\n### Sample `config.conf`\n\n```ini\n[AI]\n# Default AI service.\ndefault_ai = gemini\n\n# Default model for Gemini (options: gemini-3.0-pro, gemini-3.0-flash, gemini-3.0-flash-thinking)\ndefault_model_gemini = gemini-3.0-flash\n\n# Gemini cookies (leave empty to use browser_cookies3 for automatic authentication).\ngemini_cookie_1psid =\ngemini_cookie_1psidts =\n\n[EnabledAI]\n# Enable or disable AI services.\ngemini = true\n\n[Browser]\n# Default browser options: firefox, brave, chrome, edge, safari.\nname = firefox\n\n# --- Proxy Configuration ---\n# Optional proxy for connecting to Gemini servers.\n# Useful for fixing 403 errors or restricted connections.\n[Proxy]\nhttp_proxy =\n```\n\n\u003c/details\u003e\n\n---\n\n## Project Structure\n\nThe project now follows a modular layout that separates configuration, business logic, API endpoints, and utilities:\n\n```plaintext\nsrc/\n├── app/\n│   ├── __init__.py\n│   ├── main.py                # FastAPI app creation, configuration, and lifespan management.\n│   ├── config.py              # Global configuration loader/updater.\n│   ├── logger.py              # Centralized logging configuration.\n│   ├── endpoints/             # API endpoint routers.\n│   │   ├── __init__.py\n│   │   ├── gemini.py          # Endpoints for Gemini (e.g., /gemini, /gemini-chat).\n│   │   ├── chat.py            # Endpoints for translation and OpenAI-compatible requests.\n│   │   └── google_generative.py  # Google Generative AI v1beta API endpoints.\n│   ├── services/              # Business logic and service wrappers.\n│   │   ├── __init__.py\n│   │   ├── gemini_client.py   # Gemini client initialization, content generation, and cleanup.\n│   │   └── session_manager.py # Session management for chat and translation.\n│   └── utils/                 # Helper functions.\n│       ├── __init__.py\n│       └── browser.py         # Browser-based cookie retrieval.\n├── models/                    # Models and wrappers (e.g., MyGeminiClient).\n│   └── gemini.py\n├── schemas/                   # Pydantic schemas for request/response validation.\n│   └── request.py\n├── config.conf                # Application configuration file.\n└── run.py                     # Entry point to run the server.\n```\n\n---\n\n## Developer Documentation\n\n### Overview\n\nThe project is built on a modular architecture designed for scalability and ease of maintenance. Its primary components are:\n\n- **app/main.py:** Initializes the FastAPI application, configures middleware, and manages application lifespan (startup and shutdown routines).\n- **app/config.py:** Handles the loading and updating of configuration settings from `config.conf`.\n- **app/logger.py:** Sets up a centralized logging system.\n- **app/endpoints/:** Contains separate modules for handling API endpoints. Each module (e.g., `gemini.py` and `chat.py`) manages routes specific to their functionality.\n- **app/services/:** Encapsulates business logic, including the Gemini client wrapper (`gemini_client.py`) and session management (`session_manager.py`).\n- **app/utils/browser.py:** Provides helper functions, such as retrieving cookies from the browser for authentication.\n- **models/:** Holds model definitions like `MyGeminiClient` for interfacing with the Gemini Web API.\n- **schemas/:** Defines Pydantic models for validating API requests.\n\n### How It Works\n\n1. **Application Initialization:**  \n   On startup, the application loads configurations and initializes the Gemini client and session managers. This is managed via the `lifespan` context in `app/main.py`.\n\n2. **Routing:**  \n   The API endpoints are organized into dedicated routers under `app/endpoints/`, which are then included in the main FastAPI application.\n\n3. **Service Layer:**  \n   The `app/services/` directory contains the logic for interacting with the Gemini API and managing user sessions, ensuring that the API routes remain clean and focused on request handling.\n\n4. **Utilities and Configurations:**  \n   Helper functions and configuration logic are kept separate to maintain clarity and ease of updates.\n\n---\n\n## 🐳 Docker Deployment Guide\n\nFor Docker setup and deployment instructions, please refer to the [Docker.md](Docker.md) documentation.\n\n---\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=Amm1rr/WebAI-to-API\u0026type=Date)](https://www.star-history.com/#Amm1rr/WebAI-to-API\u0026Date)\n\n## License 📜\n\nThis project is open source under the [MIT License](LICENSE).\n\n---\n\n\u003e **Note:** This is a research project. Please use it responsibly, and be aware that additional security measures and error handling are necessary for production deployments.\n\n\u003cbr\u003e\n\n[![](https://visitcount.itsvg.in/api?id=amm1rr\u0026label=V\u0026color=0\u0026icon=2\u0026pretty=true)](https://github.com/Amm1rr/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famm1rr%2Fwebai-to-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famm1rr%2Fwebai-to-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famm1rr%2Fwebai-to-api/lists"}