Forums

Some error in connecting to ai api

Hi , im using gpt4free library in pyhton (Github Repo). i want to generate some text using GPT in my project, this is my code :

from g4f.client import Client

client = Client()
response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=[{"role": "user", "content": "what is the capital of Saudi Arabia"}],
)
print(response.choices[0].message.content)

its work normally in my device , but its not in pythonanywhere , i got this error :

g4f.errors.RetryProviderError: RetryProvider failed:
Airforce: ClientConnectorError: Cannot connect to host api.airforce:443 ssl:default [None]
Nexra: ClientConnectorError: Cannot connect to host nexra.aryahcr.cc:443 ssl:default [Connect call failed ('72.167.65.7', 443)]
OpenaiChat: ClientConnectorError: Cannot connect to host chatgpt.com:443 ssl:default [None]
Liaobots: ClientConnectorError: Cannot connect to host liaobots.work:443 ssl:False [None]
ChatGptEs: ClientConnectorError: Cannot connect to host chatgpt.es:443 ssl:default [Connect call failed ('212.53.165.225', 443)]

can you guys allow that connection or anything help? Thanks

Free accounts can only access http(s) sites on our Allowlist. See http://help.pythonanywhere.com/pages/403ForbiddenError/ for details. If the site has a publicly documented API. You'll find all the instructions for requesting allowlist additions here: https://help.pythonanywhere.com/pages/RequestingAllowlistAdditions.