gpt4free icon indicating copy to clipboard operation
gpt4free copied to clipboard

Use the G4F AsyncClient API

Open RezaRamezanisani opened this issue 1 year ago • 3 comments

Do I need to get GPT chat API to use AsyncClient API?

this is my error:

Traceback (most recent call last):
  File "C:\gpt4\chat.py", line 25, in <module>
    asyncio.run(main())
  File "C:\Users\Gigabyte\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Gigabyte\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Gigabyte\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\gpt4\chat.py", line 21, in main
    responses = await asyncio.gather(task1, task2)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\gpt4\g4f\client\async_client.py", line 63, in iter_append_model_and_provider
    async for chunk in response:
  File "C:\gpt4\g4f\client\async_client.py", line 37, in iter_response
    async for chunk in response:
  File "C:\gpt4\g4f\Provider\needs_auth\OpenaiChat.py", line 381, in create_async_generator
    await raise_for_status(response)
  File "C:\gpt4\g4f\requests\raise_for_status.py", line 24, in raise_for_status_async
    raise CloudflareError(f"Response {response.status}: Cloudflare detected")
g4f.requests.raise_for_status.CloudflareError: Response 403: Cloudflare detected

RezaRamezanisani avatar May 18 '24 11:05 RezaRamezanisani

Hey, OpenAI doesn't seem to like your IP address. You might need to set up a proxy to access it.

hlohaus avatar May 18 '24 22:05 hlohaus

What is the workaround? Thank

RezaRamezanisani avatar May 19 '24 08:05 RezaRamezanisani

As a potential solution, you could consider utilizing a proxy server or a virtual private network (VPN). By doing so, your IP address will be modified, potentially resolving the issue at hand.

hlohaus avatar May 19 '24 17:05 hlohaus