Skip to content

Amm1rr/WebAI-to-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Disclaimer

This is a research project. Please do not use it commercially and use it responsibly.


WebAI-to-API

Logo

WebAI-to-API is a modular web server built with FastAPI, designed to manage requests across AI services like Gemini and Claude. It supports configurable setups and streamlined integration. Please note:

  • Currently, Gemini is functional.
  • Claude is under development and will be supported soon.

Features

  • 🌐 Endpoints Management:
    • /v1/chat/completions
    • /gemini
    • /claude
  • 🔄 Service Switching: Configure Gemini and Claude in config.conf.
  • 🛠️ Modular Architecture: Easy to extend and maintain.

Endpoints Documentation


Installation

  1. Clone the repository:

    git clone https://github.com/Amm1rr/WebAI-to-API.git
    cd WebAI-to-API
  2. Install dependencies using Poetry:

    poetry install
  3. Create a configuration file:

    cp webaitoapi/config.conf.example webaitoapi/config.conf
  4. Edit webaitoapi/config.conf to set up your desired service settings.

  5. Run the server:

    poetry run python webaitoapi/main.py

Usage

Send a POST request to /v1/chat/completions:

Example Request

{
  "model": "gemini",
  "messages": [{ "role": "user", "content": "Hello!" }]
}

Example Response

{
  "id": "chatcmpl-12345",
  "object": "chat.completion",
  "created": 1693417200,
  "model": "gemini",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hi there!"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ]
}

Project Structure

.
├── assets
│   └── (Screenshots)
├── LICENSE
├── poetry.lock
├── Prompt.txt
├── pyproject.toml
├── README.md
├── requirements.txt
└── webaitoapi
    ├── config.conf.example
    ├── __init__.py
    ├── main.py
    └── models
        ├── claude.py
        ├── deepseek.py
        └── gemini.py

Roadmap

  • ✅ Support for Gemini.
  • 🟡 Development for Claude (in progress).
  • 🔬 Experimental model: DeepSeek (not yet operational).

Configuration ⚙️

Key Configuration Options

Section Option Description Example Value
[AI] default_ai /v1/chat/completions gemini
[EnabledAI] gemini, claude, deepseek Enable/disable provider true
[Browser] name Browser for cookie-based auth firefox

The full configuration template is available in config.conf.example.
Leave the cookies field empty to use browser_cookies3 and the default browser selected in the config file for automatic authentication.


config.conf

```
[AI]
# Set the default AI service to be used.
# Options: gemini, claude
default_ai = gemini

# Specify the default model for the Gemini AI service.
# Available options:
# "gemini-1.5-flash", "gemini-2.0-flash-exp", "gemini-1.5-pro"
default_model_gemini = gemini-1.5-pro

# Specify the default model for the Claude AI service.
# Available options:
# "claude-3-sonnet-20240229", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022"
default_model_claude = claude-3-5-sonnet-20241022

[Cookies]
# Provide cookies required for the Claude AI service.
claude_cookie =

# Provide cookies required for the Gemini AI service.
gemini_cookie_1psid =
gemini_cookie_1psidts =

[Deepseek]
# Token for Deepseek AI service integration.
user_token =

[EnabledAI]
# Enable or disable each AI service.
# Use "true" to enable or "false" to disable.
claude = false
gemini = true
deepseek = false

[Browser]
# Specify the default browser for any required operations.
# Options: firefox, brave, chrome, edge, safari
name = firefox
```
  • Located at webaitoapi/config.conf.
  • Switch between Gemini and Claude services.
  • Example configuration is provided in config.conf.example.

License 📜

This project is open source under the MIT License.


Note: This is a research project. Please use it responsibly and avoid commercial use. Additional security configuration and error handling are required for production use.