# Error with gradio application with openai

**URL:** <https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898>\
**Category:** 🔒 Gradio\
**Created:** [June 20, 2023, 8:41am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898 "2023-06-20T08:41:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soportetotem](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@soportetotem](https://discuss.huggingface.co/u/soportetotem)\
**Post date:** [June 20, 2023, 8:41am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898/1 "2023-06-20T08:41:46Z")

</div>

Hello everyone, yesterday I created a simple app in hugging face platform. The app is just a gradio chat integrated with openai.

The app was working fine yesterday however today everytime I try to ask something to the chat it gives the following error:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):  
File “/home/user/.local/lib/python3.10/site-packages/gradio/routes.py”, line 437, in run\_predict  
output = await app.get\_blocks().process\_api(  
File “/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py”, line 1352, in process\_api  
result = await self.call\_function(  
File “/home/user/.local/lib/python3.10/site-packages/gradio/blocks.py”, line 1077, in call\_function  
prediction = await anyio.to\_thread.run\_sync(  
File “/home/user/.local/lib/python3.10/site-packages/anyio/to\_thread.py”, line 33, in run\_sync  
return await get\_asynclib().run\_sync\_in\_worker\_thread(  
File “/home/user/.local/lib/python3.10/site-packages/anyio/\_backends/\_asyncio.py”, line 877, in run\_sync\_in\_worker\_thread  
return await future  
File “/home/user/.local/lib/python3.10/site-packages/anyio/\_backends/\_asyncio.py”, line 807, in run  
result = context.run(func, \*args)  
File “/home/user/app/app.py”, line 13, in chatbot  
chat = openai.ChatCompletion.create(  
File “/home/user/.local/lib/python3.10/site-packages/openai/api\_resources/chat\_completion.py”, line 25, in create  
return super().create(\*args, \*\*kwargs)  
File “/home/user/.local/lib/python3.10/site-packages/openai/api\_resources/abstract/engine\_api\_resource.py”, line 153, in create  
response, \_, api\_key = requestor.request(  
File “/home/user/.local/lib/python3.10/site-packages/openai/api\_requestor.py”, line 288, in request  
result = self.request\_raw(  
File “/home/user/.local/lib/python3.10/site-packages/openai/api\_requestor.py”, line 609, in request\_raw  
raise error.APIConnectionError(  
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘[api.openai.com](http://api.openai.com)’, port=443): Max retries exceeded with url: /v1/chat/completions (Caused by NewConnectionError(‘\<urllib3.connection.HTTPSConnection object at 0x7f3e8525d9c0\>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution’))

Not sure why today is having that error

Any idea?

I also have the same application in a virtual machine and it works fine there, the only place it does not work is in huggingface

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![anon22701748](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anon22701748](https://discuss.huggingface.co/u/anon22701748)\
**Post date:** [June 20, 2023, 8:44am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898/2 "2023-06-20T08:44:54Z")

</div>

probably related to [Build error without log](https://discuss.huggingface.co/t/build-error-without-log/43884) and others like it.

---

<div class="post-metadata">

**Author:** ![soportetotem](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@soportetotem](https://discuss.huggingface.co/u/soportetotem)\
**Post date:** [June 20, 2023, 8:48am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898/3 "2023-06-20T08:48:08Z")

</div>

Hey thanks for the reply. I restarted the space and the app was built without any errors. The errors appeared when I interacted with the chatbot

---

<div class="post-metadata">

**Author:** ![anon22701748](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@anon22701748](https://discuss.huggingface.co/u/anon22701748)\
**Post date:** [June 20, 2023, 8:50am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898/4 "2023-06-20T08:50:01Z")

</div>

Oh yay! My spaces are now building too. 🙂 [party!]

---

<div class="post-metadata">

**Author:** ![soportetotem](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@soportetotem](https://discuss.huggingface.co/u/soportetotem)\
**Post date:** [June 20, 2023, 8:57am UTC](https://discuss.huggingface.co/t/error-with-gradio-application-with-openai/43898/5 "2023-06-20T08:57:56Z")

</div>

Now it works, looks like it was something related to huggingface environment 🙂
