Reverse proxy for OpenAI chatgpt website API
Project description
ChatGPT-Proxy
Python version of OpenAI's ChatGPT web API proxy
Python alternative to ChatGPT-Proxy-V4
Use cookie _puid
to bypass Cloudflare browser check
Requirements
- ChatGPT plus account
- Access to chat.openai.com
Install
pip install chatgpt-proxy
Usage
Run as a service
Set these environment variables:
PUID
: Preset cookie_puid
ACCESS_TOKEN
: (Optional) For automatic refresh of_puid
, obtains from herePROXY_TRUST_CLIENT
: (Optional) Trust requests from any client.
When set toTrue
, any requests without an access_token will be given the above access_token.
Default toFalse
, which will only use for refresh puid.HOST
: (Optional) Listen on host, default to127.0.0.1
PORT
: (Optional) Listen on port, default to7800
Run: python -m chatgpt_proxy
Integrate into your FastAPI app
Check out __main__.py
from chatgpt_proxy import WebChatGPTProxy
proxy = WebChatGPTProxy(puid=PUID, access_token=ACCESS_TOKEN, trust=False)
@asynccontextmanager
async def lifespan(app: FastAPI):
# add this to start refresh puid task
refresh_puid_task = asyncio.create_task(proxy._refresh_task())
yield
app = FastAPI(lifespan=lifespan)
proxy.attach(app, path="/backend-api")
class WebChatGPTProxy
:
puid
: Preset cookie_puid
access_token
: (Optional), for automatic refresh of_puid
trust
: Trust requests from any client. When set to True, any requests without an access_token will be given the above access_token. Default to False, which will only use for refresh puid.
Credits
- ChatGPT-Proxy-V4 https://github.com/acheong08/ChatGPT-Proxy-V4
- Implement reverse proxy in FastAPI https://github.com/tiangolo/fastapi/discussions/7382#discussioncomment-5136454
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chatgpt-proxy-0.0.4.tar.gz
(16.1 kB
view hashes)
Built Distribution
Close
Hashes for chatgpt_proxy-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68abdc185b4fa9c91bd67669cb5e3a8cd296a4b96ea80e1888661643cd988f7b |
|
MD5 | 34e2c222a2933352f50cdf2dbfad50b2 |
|
BLAKE2b-256 | 03fa178cd05fb9fba6dcf46df9a1cbf1dd371d768036cdc6669431199abd8867 |