My OpenAI API key can't verify with (status code 0) TypeError: Failed to fetch error

I have create a API key ,but when I verifing it can’t work and feedback a error:Failed to fetch error.

info:(status code 0)
TypeError: Failed to fetch

curl https://api.openai.com/v1/chat/completions -H “Content-Type: application/json” -H “Authorization: Bearer sk-proj-XXXXX” -d “{ "messages": [ { "role": "system", "content": "You are a test assistant." }, { "role": "user", "content": "Testing. Just say hi and nothing else." } ], "model": "gpt-4o-mini" }”

How can I fix it

1 Like

Need help :persevere:

Hey, sorry you’re having issues getting your API key working!

Does the curl command suggested by Cursor work when you run it in your own terminal?

Hello!
I have the same issue, curl command response is 200.

Hi,

Did you find a solution to this problem? I’m facing the same issue

Thanks!