Zima
March 2, 2023, 8:40am
1
OK Guys. I need a hint
I am posting literally this:
{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “user”, “content”: “Hello!”}]
}
and still getting
{
“message”: “Invalid URL (POST /v1/chat/completions)”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
It does read the json as when I break it, it gives me an error.
The API key works as when I delete a char, I get key error and davinci works just fine.
3 Likes
Have u fix it? I’m having the same problem
1 Like
Can you post a sample of your code without your API key so we can see if there is anything obvious
i have same problem
without API key
$ curl https://api.openai.com/v1/chat/completions \
> -H 'Content-Type: application/json' \
> -H 'Authorization: Bearer YOUR_API_KEY' \
> -d '{
> "model": "gpt-3.5-turbo",
> "messages": [{"role": "user", "content": "Hello!"}]
> }'
{
"error": {
"message": "Incorrect API key provided: YOUR_API_KEY. You can find your API key at https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}
have API key
curl https://api.openai.com/v1/chat/completions \
> -H 'Content-Type: application/json' \
> -H 'Authorization: Bearer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■iFfot41G' \
> -d '{
> "model": "gpt-3.5-turbo",
> "messages": [{"role": "user", "content": "Hello!"}]
> }'
{
"error": {
"message": "Invalid URL (POST /v1/chat/completions)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Who fixed it?
The same problem with me, I need some hints.
FWIW, curl
as in the above example, works fine:
MacStudio$ curl https://api.openai.com/v1/chat/completions -H 'Content-Type: application/json' -H 'Authorization: Bearer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■kfdsfPlMtwQvvg' -d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
{"id":"chatcmpl-6qxJ88qUEJ3ZltZ7daTOIUXAt9COb","object":"chat.completion","created":1678079054,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":9,"completion_tokens":12,"total_tokens":21},"choices":[{"message":{"role":"assistant","content":"\n\nHi there! How can I assist you today?"},"finish_reason":"stop","index":0}]}
HTH
It doesn’t work for me even from curl with the example request from guide. Is it relate to the API Key or account ?
curl -X POST https://api.openai.com/v1/chat/completions -H “Content-Type: application/json” -H "Authorization: Bearer sk-J ********************************n" -d “{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello!"}]}”
{
“error”: {*
“message”: “Invalid URL (POST /v1/chat/completions)”,*
“type”: “invalid_request_error”,*
“param”: null,*
“code”: null*
}*
}
By the way, are you using ChatGPT Plus account?
API access is totally separate than ChatGPT monthly subscriptions.
so why even curl request not working for me . IP policy? But I can use web version without problem
hey guys, i fixed the problem by switching to another account, in fact, maybe some accounts do
What kind of account is required?
Is plus or free account?
5km
March 13, 2023, 5:35am
13
Is the account without any invalid request error a free account?
Zima
March 13, 2023, 9:01am
14
Switchong accoungs is not really a fix.
I was having problems but got the above working (not sure what I did). I have a free account (meaning paid API only) and a ChatGPT+ and the paid account takes 12 seconds and the “free” one takes less than a second for that simple example.
avanlaningham:
meaning paid API only
What model are you using in your API call?
text-davinci-003
?
ruby_coder:
text-davinci-003
This model does not work for me for some reason. It gives some error. I think it requires a different param for messages:[…]
If you read the API reference you will know the reason.
Its all there, in two minutes of API doc reading.
You must read better than I am.
Going here it shows in the first paragraph a link to models and it includes text-davinci-003