I am trying to use the API to do text embedding for training a classification model. I obtained a new API code and use this line of code, as suggested by the API website, to test it: response = openai.Completion.create(model=“text-davinci-003”, prompt=“Say this is a test”, temperature=0, max_tokens=7, verify=False). Below is the error message I got:
APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries exceeded with url: /v1/completions (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’)))
I am not able to put the entire trackback here for it is too long. I am using my company’s computer for this project: Windows 10 Enterprise, version 21H2, Processor: 11th Gen Intel(R) Core™ i7-11850H @ 2.50GHz 2.50 GHz. 64-bit operating system, x64-based processor.
I’m getting a similar error using python. Nor can I hit the site to get the certs.
raise error.APIConnectionError(
openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host=‘api.openai.com’, port=443): Max retries exceeded with url: /v1/engines/text-davinci-002/completions (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:997)’)))
@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.
@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 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
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.
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.
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?