@vasundhra362000 Please you can also get certs from openai.
@freelanceer.nak Could you please mind sharing the page url from where we can download the certs ? Have tried going to the personal page (where we create the token, but to no avail). Irony of it - asked chatGPT itself the same question, and it asked me to raise a case with support.
Appreciate your response.
@aporelpan are you using a company/work laptop to connect to this API by chance. I experienced the same error and it turned out to be my company’s VPN blocking access to OpenAI API. Disabled the VPN and it worked!
I am also getting the error that SSLCertVerificationFailed.
I had to get the certificates from www.api.openai.com, copy them, and paste them into the Python cacert.pem file. The bad thing is that you have to repeat this every time they update the certificates.
I also encountered such a problem. If I run the. py file in vscode, I will get an error, but if I run the jupyter file in Chrome, it will run very well.
I use nodejs on centos7,nodejs log file: Error with OpenAI API request: Error: certificate has expired,
I update ca root certificate
yum -y install ca-certificates openssl (update version)
update-ca-trust force-enable
update-ca-trust extract
and fixed it.
You can try update ca root certificate
Thank you @PaulBellow , this resolved my problem!
search on “Certificates.command” in your Mac finder to locate the file, and you’ll need to run it as root.
None of these solutions worked for the API. I still get CERTIFICATE_VERIFY_FAILED error when using Python in a Jupyter notebook. This is on Windows using a VPN. I can get to the OpenAI playground and everything works. I added the certificate from the locations referenced above, but it would be nice if someone would post specific steps that they have used to resolve this issue. I’ve tried all the suggestions, but nothing works. I have a hard time believing this OpenAI Python library works at all.
Has anyone gotten the Python OpenAI API library to work without getting this certificate_verify_failed while also using a VPN?
Openai has got the variable verify_ssl_certs set to True and setting it to False has no effect…Wow.
Line 42 openai-python/init.py at 75c90a71e88e4194ce22c71edeb3d2dee7f6ac93 · openai/openai-python · GitHub
verify_ssl_certs = True # No effect. Certificates are always verified.
Anyone have any luck with the ssl fail error, I’ve been stuck on it for days.
Is there any other place I can get the cert from? The open AI site is just not cutting the mustard.
I was able to resolve this issue at my end by following below steps:
-
Visit https://api.openai.com/v1/engines from the browser and cancel the password prompt
-
Click on the lock icon on near the browser url to get the certificate info
-
Depending on your browser find the certificate details and download the root certificate file. For chrome click on connection is secure → Certificate is valid → Details tab and select the top most certificate and click export.
-
Once downloaded move it to the folder where you need it stored
-
Add the below code in your main app code to set the environment variable pointing to this certificate we downloaded
import os
os.environ['REQUESTS_CA_BUNDLE'] = '/path/to/certificate.crt'
OR
you can create a .env file in the local folder of your app with below line in it
REQUESTS_CA_BUNDLE = ‘/path/to/certificate.crt’
and load the environment variables in your code file using below code
from dotenv import load_dotenv
load_dotenv()
- Once environmental variable is set, openai library in python will use this certificate file for validation automatically and will resolve the issue.
I hope steps would help to resolve the issue for anyone facing it.
Hi - I am still facing issue with this approach. Am i missing anything here?
import os
import openai
os.environ[‘REQUESTS_CA_BUNDLE’] = ‘path to crt file’
openai.api_key = ‘key’
response = openai.Completion.create(
model=“text-davinci-003”,
prompt=“Summarize this for a second-grade student:\n\nJupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.”,
temperature=0.7,
max_tokens=256,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
Are you going through a VPN? I am going through a corporate VPN (Global Protect) and it will not allow SSL verify to complete correctly no matter what is tried. All of these solutions here fail. None of them work through this particular VPN solution.
I guess it’s no surprise since it is from Palo Alto Networks. Their software is buggy. There was recently discovered a bug in Global Protect or Palo Alto Networks appliance that is causing connectivity issue where connections are just dropped.
If you are using a VPN, what happens if you disconnect the VPN? Does the request complete successfully?
This works if i disconnect the VPN… It looks like it never works with vpn connected…
Well, that’ the same here. I have sent info to my security folks here and they haven’t gotten back to say they found any issue associated with the VPN config.
It still could be something wrong with the VPN, but there are an awful lot of people experiencing this issue when using the OpenAI Python library. I don’t have this issue when using requests. When it has happened in the past, it was very simple resolution, just export the cert from the site and add to the cacerts.pem file for the Python virtual environment. I have tried that in this case by getting the cert from api.openai.com. The cert doesn’t look quite right so maybe there’s something wrong with OpenAI’s self-signed certificate which would be ironic because the OpenAI Python library keeps complaining about a self-signed certificate in the chain.
Seriously though, OpenAI, can’t you put some resources on this to fix it so people can use it. It’s almost like you want people to NOT use your products. Or, at the very least, provide some guidance for those customers using some of the more popular VPNs out there like GlobalProtect, Cisco, etc.
This worked, thanks! Also, remember when clicking the lock icon on the left side of the URL, to select “Connection is Secure” to access the certificate. (In Google Chrome anyway)
This worked like a charm, thanks!! I pasted the certificate in my venv at [envname]/Lib/site-packages/certify
Hi Friends,
i’m facing the same issue, but with Azure OpenAI
here’s the error, pls suggest
APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='azuresandbox1.openai.azure.com', port=443): Max retries exceeded with url: //openai/deployments/rak-gpt-35-turbo/completions?api-version=2022-12-01 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai
openai.api_type = "azure"
openai.api_base = "https://azuresandbox1.openai.azure.com/"
openai.api_version = "2022-12-01"
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.Completion.create(
engine="raj-gpt-35-turbo",
prompt="Generate a summary of the below conversation in the following format:\nCustomer problem:\nOutcome of the conversation:\nAction items for follow-up:\nCustomer budget:\nDeparture city:\nDestination city:\n\nConversation:\nUser: Hi there, I’m off between August 25 and September 11. I saved up 4000 for a nice trip. If I flew out from San Francisco, what are your suggestions for where I can go?\nAgent: For that budget you could travel to cities in the US, Mexico, Brazil, Italy or Japan. Any preferences?\nUser: Excellent, I’ve always wanted to see Japan. What kind of hotel can I expect?\nAgent: Great, let me check what I have. First, can I just confirm with you that this is a trip for one adult?\nUser: Yes it is\nAgent: Great, thank you, In that case I can offer you 15 days at HOTEL Sugoi, a 3 star hotel close to a Palace. You would be staying there between August 25th and September 7th. They offer free wifi and have an excellent guest rating of 8.49/10. The entire package costs 2024.25USD. Should I book this for you?\nUser: That sounds really good actually. Please book me at Sugoi.\nAgent: I can do that for you! Can I help you with anything else today?\nUser: No, thanks! Please just send me the itinerary to my email soon.\n\nSummary: \nCustomer problem: The customer wants to travel between August 25 and September 11 with a budget of 4000 USD from San Francisco to a destination suggested by the agent.\nOutcome of the conversation: The agent suggested Japan as a destination and offered a 15-day stay at a 3-star hotel called Sugoi. The customer agreed to the offer and the agent booked the hotel for the customer.\nAction items for follow-up: The agent needs to send the itinerary to the customer's email.\nCustomer budget: 4000 USD\nDeparture city: San Francisco\nDestination city: Japan (exact location not specified)<|im_end|>",
temperature=0.3,
max_tokens=350,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
stop=None)
