Skip to content

Amm1rr/WebAI-to-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Free Chatbot API

This project implements a Python web API that offers free access to three leading AI chatbots ChatGPT, Google Bard, and Claude through a single interface.

Key features:

  • Unified API endpoints allow seamlessly querying ChatGPT, Google Bard, and Claude from one integration.
  • Leverages the free web/browser versions of each AI service by managing cookies and sessions. Avoid costs of paid API access.
  • Simple API for text completion, question answering, and conversational queries. Integrate AI capabilities easily.
  • Lightweight Python server using FastAPI. Easily self-host locally or on your own infrastructure.
  • Full support for streaming responses.

It's a personal project to use tools like ShellGPT and others.

  • Google Bard integration available now.
  • Claude-2 integration is also fully implemented and available.
  • ChatGPT integration is fully complete and available now.

Image


Upcoming Tasks

  • Implement OpenAI endpoints for ChatGPT, (v1/chat/completions)
  • Use proxy
  • Use multiple accounts

NOTE: This project is currently under active development.


Usage

How to Find Your Free Tokens

First you need to add your tokens to the Config.conf file (see Configuration section).


Google Bard

Image

Google Bard: Please obtain the cookies mentioned here from an authorized session on bard.google.com. The cookies can be used to send POST requests to the /bard endpoint along with a message in a JSON payload. It is important that the session_id, which is your Secure-1PSID cookie, is included in the request. (Screenshot)

  1. Login to bard.google.com
  2. Open Developer Tools (Press F12)
  3. Go to Application Tab
  4. Go to Cookies Tab
  5. Copy the content of __Secure-1PSID
  6. Set in Config.conf file.



Claude 2

Image

Claude: You can get cookie from the browser's developer tools network tab ( see for any claude.ai requests check out cookie ,copy whole value ) or storage tab ( You can find cookie of claude.ai ,there will be four values ) (Screenshot)

  1. Login to claude.ai/chats
  2. Open Developer Tools (Press F12)
  3. Go to Network Tab
  4. Select an ajax request (like step 3 in picture)
  5. Copy the content of Cookie
  6. Set in Config.conf file.




ChatGPT

Image

ChatGPT: Please obtain the sessions mentioned here from an authorized session on chat.openai.com. The sessions can be used to send POST requests to the /chatgpt endpoint along with a message in a JSON payload. It is important that the session_id, which is your Authorization header session, is included in the request. (Screenshot)

  1. Login to chat.openai.com
  2. at least ask any question.
  3. Open Developer Tools (Press F12)
  4. Go to Network Tab
  5. Select an ajax request (like step 4 in picture)
  6. Copy the content of Authorization
  7. Set in Config.conf file.



Prerequisites

(NOTE: This guide is still in progress.)

Before using the APIs, sign up for free accounts to get access credentials if you don't already have them:

Then, add your token(s) to the Config.conf file. (see Configuration section).


Installation


Step 1. Clone Repository

git clone https://github.com/Amm1rr/Free-Chatbot-API.git && cd Free-Chatbot-API

python -m .venv venv

source .venv/bin/activate


pip install -r requirements.txt

Step 2. Start Web Server

Navigate into the src directory, and run the web server using one of the methods below:

uvicorn main:app --reload --port 8000

-- OR --

python main.py

-- OR --

./Run-Server.sh

Available Endpoints:

---------- Google Bard

http://128.0.0.1:8000/bard


---------- Claude

http://128.0.0.1:8000/claude


---------- ChatGPT

http://128.0.0.1:8000/chatgpt

Input / Output

Input:
_____

    {
      "session_id": "your-session-id",
      "message": "Hi, Who are you?",
      "stream": True
    }

--------------------
--------------------

Output:
_____

    {
      I'm a Chatbot assistant :)
    }


Example

try Claude with cURL

Once you have launched the webserver using uvicorn main:app --reload --port 8000 , run this cURL command in a terminal window:

curl -X 'POST' \
  'http://localhost:8000/claude' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "message": "who are you?",
  "session_id": "",
  "stream": true
}'

Note: The session_id is configured in the Config.conf file. If you send this variable empty, it will use the Config.conf



Configuration

How to Find Your Free Tokens

Config File Path:

  • Free-Chatbot-API\src\Config.conf
# Case-Sensative

[Claude]
COOKIE=[YOURS]

[ChatGPT]
ACCESS_TOKEN=[YOURS]

[Bard]
SESSION_ID=[YOURS]


Implementation

(NOTE: This guide is still in progress.)


Sources

Google Bard API | Claude API | revChatGPT


Licensing

This project is licensed under the MIT License. Feel free to use it however you like.