mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
6.67k stars 688 forks source link

[BUG] - OpenAI API calls returning 404 in logs #4209

Open TheGief opened 4 days ago

TheGief commented 4 days ago

First Check

What is the issue you are experiencing?

In setting up the OpenAI integration I see 404s in the logs.

I can only set base url. Looking in OpenAI docs it looks like the completion URL is https://api.openai.com/v1/completions which is different than the url above.

https://platform.openai.com/docs/api-reference/completions/create?lang=curl

Steps to Reproduce

  1. Setup OpenAI using the backend configs
  2. Goto the Parser page and choose OpenAI
  3. Click submit

Please provide relevant logs

INFO 2024-09-14T14:26:18 - HTTP Request: POST https://api.openai.com/chat/completions "HTTP/1.1 404 Not Found"

Mealie Version

Nightly Build d8dbcac1964c9e485be066c6ab49feda14e31220

Deployment

Docker (Linux)

Additional Deployment Details

No response

michael-genson commented 4 days ago

If you're using Open AI you shouldn't be setting the base URL: https://docs.mealie.io/documentation/getting-started/installation/open-ai/

Additionally, if you're on the free tier, you're going to get a 404 error since you don't have access to all models, including the default one

TheGief commented 4 days ago

Heya, thanks for your response. Confirming I'm not setting the baseurl and I'm not on the free tier of OpenAI.

I think OpenAI changed the URL of the "completions" API. My guess is that the python lib you're using to hit the completions API is using and old URL "/chat/completions". I think the new URL is "/v1/completions". I tried curling both with my API key and only the new url works.

It also seems that "gtp-4o" isn't supported by the /v1/completions api. However, "gpt-3.5-turbo-instruct" is.

michael-genson commented 4 days ago

I just checked on my instance with all default settings and it works as expected. Are you sure you cleared the base URL? Are you sure your instance can reach OpenAI?

Also make sure you're on the latest nightly, which has the latest OpenAI Python client