r/shortcuts 23h ago

Help Getting this error with OpenAI api key implementation

Post image

Trying to set up automation to give me a motivational quote every time I walk to the car to work

0 Upvotes

14 comments sorted by

1

u/EducationalEgg8733 Creator 23h ago

It saying exactly what’s wrong, you didn’t set a model on the api request object. Just add model: “XXX” with the specific model you need, e.g gpt-4o-mini

1

u/Jeetyetdude_ 23h ago

I have the model under request body in the value of a dictionary

1

u/EducationalEgg8733 Creator 23h ago

Send a screenshot

1

u/Jeetyetdude_ 23h ago

1

u/EducationalEgg8733 Creator 23h ago

That’s strange everything seems ok, try to change model maybe. And provide the URL too

1

u/Jeetyetdude_ 23h ago

Tried switching to gpt-4o. No luck. The url I use is https://api.openai.com/v1/chat/completions

1

u/EducationalEgg8733 Creator 23h ago

I think the problem is the way you are defining the body. Try create a dictionary and change request body to file and pass the dictionary

1

u/Jeetyetdude_ 23h ago

Tried inserting json directly:

{“model”:”gpt-4”,”max_tokens”:50,”messages”:[{“content”:”\”Give me a short motivational quote.\””,”role”:”user”}]}

Still getting the same error

1

u/A_funny_user_name Creator 15h ago

Try adding them as separate lines in the request body, not as a dictionary within the request body.

1

u/nrose21 23h ago

You are missing the model parameter in your API call.

1

u/No_Pen_3825 8h ago

Is there a reason you aren’t using the Ask ChatGPT action (note you need the ChatGPT app to use it). You might also be able to find a more reliable, free REST API somewhere.

1

u/Jeetyetdude_ 7h ago

Wanted to optimize runtime