-3

I tried to use openai's api,but it didn't work.

It's the curl

curl https://api.openai.com/v1/chat/completions \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer $OPENAI_API_KEY" \
 -d '{
        "model": "gpt-3.5-turbo",
        "messages": [
           {"role": "system", "content": "You are a helpful assistant"},
           {"role": "user", "content": "Who won the world series in 2020?"},
           {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
           {"role": "user", "content": "Where was it played?"}
        ]
     }'

And,this is the result.

{
    "error": {
        "message": "This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?",
        "type": "invalid_request_error",
        "param": "model",
        "code": null
    }
}

I watched the openai docs,the url is right. But it didn't pass.

Thanks for your help !

Rocky-y
  • 1
  • 1

2 Answers2

0

This may also result due to OS parsing breaking the curl command parameters. e.g., on Microsoft Windows the syntax should be different

curl https://api.openai.com/v1/chat/completions 
     -H "Content-Type: application/json" 
     -H "Authorization: Bearer %OPENAI_API_KEY%" 
     -d "{ \\"model\\": \\"gpt-3.5-turbo\\", \\"messages\\": [{\\"role\\": \\"system\\", \\"content\\": \\"You are a helpful assistant\\"},{\\"role\\": \\"user\\", \\"content\\": \\"Who won the world series in 2020?\\"},{\\"role\\": \\"assistant\\", \\"content\\": \\"The Los Angeles Dodgers won the World Series in 2020.\\"}, {\\"role\\": \\"user\\", \\"content\\": \\"Where was it played?\\"}]}"
Oren N
  • 21
  • 2
-1

It may be an account issue.

I also encountered an issue where gpt-3.5-turbo cannot be used. And the result returned by text avinci-003 is very strange. My friend and I tested using the same "prompt", model, and parameters on the "playground" page of the official website, and my returned results were very strange, while his was very normal. So I speculate it's an account issue. After I opened a new account and tried, it can be used normally.