Skip to main content

Unlimited ChatGPT WebAPI

Project description

UnlimitedChatGPTWebAPI

Resolve Cloudflare Challenge To use ChatGPT Web API

Installation

pip3 install UnlimitedChatGPTWebAPI

then you should run playwright install chromium

For windows, maybe you should use it -> playwright install-deps chromium

Configuration

  1. Make sure your network or agent can access https://chat.openai.com
  2. Please make sure that the VPS RAM is not too small.

Usage

Basic example

import asyncio

from UnlimitedChatGPTWebAPI import ChatSession


async def main():
    async with ChatSession(proxies="socks5://localhost:7890") as session:
        # or use this if you want to use the same session for multiple requests
        # example:
        # session = ChatSession(proxies="socks5://localhost:7890")
        # await session.init_page()
        async with session.fetch(
            method="GET",
            url="/backend-api/models",
            headers={"Authorization": "Bearer xxx"}
        ) as resp:
            print(await resp.json())

if __name__ == "__main__":
    asyncio.run(main())

Streaming example

import asyncio

from UnlimitedChatGPTWebAPI import ChatSession


async def main():
    async with ChatSession(proxies="socks5://localhost:7890") as session:
        # or use this if you want to use the same session for multiple requests
        # example:
        # session = ChatSession(proxies="socks5://localhost:7890")
        # await session.init_page()
        async with session.fetch(
            method="GET",
            url="/backend-api/models",
            headers={"Authorization": "Bearer xxx"}
        ) as resp:
            data = b""
            async for chunk in resp.iter_chunked():
                data += chunk
            print(data.decode())

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

UnlimitedChatGPTWebAPI-0.1.2.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

UnlimitedChatGPTWebAPI-0.1.2-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page