openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

OpenAI APR error code

Open newmagicjosh opened this issue 1 year ago • 2 comments

Describe the bug

API Error on OpenAI when calling in the visual studio code. I don't know how to fix this.

raise error.APIConnectionError( openai.error.APIConnectionError: Error communicating with OpenAI: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)')))

To Reproduce

  1. install visual studio code
  2. enter: import openai

openai.api_key = "API Key"

completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Write an essay about penguins"}]) print(completion.choices[0].message.content) 3. Run: issue occurred

Code snippets

No response

OS

window

Python version

Python v2022.10.0

Library version

n/a

newmagicjosh avatar Mar 21 '23 19:03 newmagicjosh

Hi @newmagicjosh,

I'm not able to reproduce this on my end. I suspect there might be some sort of certificate issue on your end. If you have any other details that might help diagnose the issue, I'd be happy to look again.

hallacy avatar Mar 22 '23 02:03 hallacy

what do you mean by certificate issue? What certificate issues I can get? I need to know more specifically to work and make this happen.

Thank you

newmagicjosh avatar Mar 22 '23 19:03 newmagicjosh

I suspect some part of your configuration is unable to validate your local SSL cert. Maybe try something like https://komodor.com/learn/how-to-fix-ssl-certificate-problem-unable-to-get-local-issuer-certificate-git-error/ to fix this issue?

In the meantime, since I don't think this is an issue with the openai repo, I'm going to close this issue.

hallacy avatar Mar 30 '23 03:03 hallacy