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.
- ✅ Google Bard integration available now.
- ✅ Claude-2 integration is also fully implemented and available.
- ✅ ChatGPT integration is fully complete and available now.
NOTE: This is a personal project involving the use of tools such as ShellGPT , ChatGPT Code Review and...
Please use them responsibly.
This repository is up-to-date.
Python version: >= 3.10
Note: Claude and Bard offer two authentication options - you can either log in through your browser and skip this step, or you can follow the instructions below to configure the authentication.
First you need to add your tokens to the Config.conf
file (see Configuration section).
Google Bard
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)
- Login to bard.google.com
- Open
Developer Tools
(Press F12) - Go to
Application Tab
- Go to
Cookies Tab
- Copy the content of
__Secure-1PSID
and__Secure-1PSIDTS
. Copy the value of those cookie. - Set in Config.conf file.
Claude 2
Method 1:
For Claude, all you need to do is login to your account using your web browser. (Firefox, Chrome, Safari)
Method 2:
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)
- Login to claude.ai
- Open
Developer Tools
(Press F12) - Go to
Network Tab
- Select an ajax request (like step 3 in picture)
- Copy the content of
Cookie
- Set in Config.conf file.
ChatGPT
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)
- Login to chat.openai.com
- at least ask any question.
- Open
Developer Tools
(Press F12) - Go to
Network Tab
- Select an ajax request (like step 4 in picture)
- Copy the content of
Authorization
- Set in Config.conf file.
Before using the APIs, sign up for free accounts to get access credentials if you don't already have them:
- ChatGPT: https://openai.com/api/
- Google Bard: https://bard.google.com/
- Claude: https://claude.ai/
Then, add your token(s) to the Config.conf
file. (see Configuration section).
Note: Claude and Bard offer two authentication options - you can either log in through your browser and skip this step.
git clone https://github.com/Amm1rr/Free-Chatbot-API.git && cd Free-Chatbot-API
python -m venv .venv
source .venv/bin/activate # Linux or macOS
.venv\Scripts\activate # Windows
pip install -r requirements.txt
Navigate into the src
directory, and run the web server using one of the methods below:
cd src/
python main.py
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
#---------- ChatGPT JSON Response
http://128.0.0.1:8000/v1/chat/completions/
#---------- ChatGPT for ShellGPT
http://128.0.0.1:8000/v1/chat/completions/ShellGPT
#---------- ChatGPT for Code Review
http://128.0.0.1:8000/v1/chat/completions/CodeReview
1- ShellGPT | 2- ChatGPT Code Review
Input / Output
# Input:
_____
{
"session_id": "your-session-id",
"message": "Hi, Who are you?",
"stream": True
}
--------------------
# Output:
_____
{
I'm a Chatbot assistant :)
}
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
Note: Claude and Bard presents two authentication options - logging in through your browser or configuring Claude using the provided config file.
- Free-Chatbot-API\src\Config.conf
# Case-Sensative
[Claude]
COOKIE=[YOURS]
[Bard]
SESSION_ID=[YOURS]
[ChatGPT]
ACCESS_TOKEN=[YOURS]
Google Bard API | Claude API | revChatGPT
This project is licensed under the MIT License. Feel free to use it however you like.