# Proxy exclusion for API, NO\_PROXY=api.openai.com?

**URL:** <https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637>\
**Category:** API\
**Created:** [March 24, 2024, 1:41pm UTC](https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637 "2024-03-24T13:41:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zlota](https://avatars.discourse-cdn.com/v4/letter/z/2bfe46/32.png) [@Zlota](https://community.openai.com/u/Zlota)\
**Post date:** [March 24, 2024, 1:41pm UTC](https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637/1 "2024-03-24T13:41:51Z")

</div>

Hi, I’m currently trying to exclude the calls I make to the api from running through my proxy because it seems to have been blocked for some reason (it’s located in the US).  
Anyway, I would like to do something like :  
NO\_PROXY=[http://openai.com](http://openai.com)  
and the request would be runned on my IP not through the proxy, the issue is, it doesn’t seem to work. I can run my python script properlly when I use my IP so it is not an implementation issue.

I couldn’t get things like :

\_http\_client = \_httpx.Client(proxies=proxies)  
chatgpt\_client = OpenAI(api\_key=api\_key,  
http\_client=\_http\_client # Configure a custom httpx client)

to work either, it said :

Request URL is missing an ‘http://’ or ‘https://’ protocol.

to the best of my knowledge this would be a httpx error but I couldn’t solve it.

I also tried setting some ENV variable like OPENAI\_PROXY but same thing, doesn’t seem to work.

If anyone has idea I would gladly take them !  
Thanks.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [March 24, 2024, 2:42pm UTC](https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637/2 "2024-03-24T14:42:57Z")

</div>

I put a forward proxy on my firewall with a bad cert SSL catcher, and configured the OS to use it. It broke my Python chatbot.

Then added this to make it work again:

```auto
import os
from openai import OpenAI
try:
    os.environ['NO_PROXY'] = os.environ['NO_PROXY'] + ',' + 'api.openai.com'
except:
    os.environ['NO_PROXY'] = 'api.openai.com'
    
client = OpenAI()

```

The httpx library that the openai python SDK module uses respects this no\_proxy environment variable.

---

<div class="post-metadata">

**Author:** ![Zlota](https://avatars.discourse-cdn.com/v4/letter/z/2bfe46/32.png) [@Zlota](https://community.openai.com/u/Zlota)\
**Post date:** [March 24, 2024, 11:21pm UTC](https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637/3 "2024-03-24T23:21:49Z")

</div>

I tried, it didn’t seem to help but I managed to fix my issue.  
It actually had nothing to do with the proxy being banned at least I don’t think so, but it had to do with the character Pi going through the proxy with the request and somehow bugged everything.

It was a nightmare to debug but thanks anyway for your idea.

---

<div class="post-metadata">

**Author:** ![N2U](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/n2u/32/54438_2.png) [@N2U](https://community.openai.com/u/N2U)\
**Post date:** [May 6, 2024, 7:01pm UTC](https://community.openai.com/t/proxy-exclusion-for-api-no-proxy-api-openai-com/695637/4 "2024-05-06T19:01:25Z")

</div>


