I was using the ChatGPT and it says to use this line of code for the API endpoint:
$endpoint = 'https://api.openai.com/v1/engines/text-davinci-003/completions';
But it doesn't work. I get the following error:
{ "error": { "message": "The model `text-davinci-003` has been deprecated, learn more here: https://platform.openai.com/docs/deprecations", "type": "invalid_request_error", "param": null, "code": "model_not_found" } }
I can't really find anything to fix it.
I tried changing the models in the URL itself but it didn't work.
There are two problems with your code.
1. You're trying to use a deprecated OpenAI model
On January 4, 2024, OpenAI deprecated a lot of models.
See the deprecated models and recommended replacements in the tables below.
In your case, change
text-davinci-003forgpt-3.5-turbo-instruct.Instruct GPT models
text-ada-001gpt-3.5-turbo-instructtext-babbage-001gpt-3.5-turbo-instructtext-curie-001gpt-3.5-turbo-instructtext-davinci-001gpt-3.5-turbo-instructtext-davinci-002gpt-3.5-turbo-instructtext-davinci-003gpt-3.5-turbo-instructBase GPT models
adababbage-002babbagebabbage-002curiedavinci-002davincidavinci-002code-davinci-002gpt-3.5-turbo-instructFine-tuning GPT models
adababbage-002babbagebabbage-002curiedavinci-002davincidavinci-002,gpt-3.5-turbo,gpt-4Edit models
text-davinci-edit-001gpt-4code-davinci-edit-001gpt-4Embedding models
text-similarity-ada-001text-embedding-ada-002text-search-ada-doc-001text-embedding-ada-002text-search-ada-query-001text-embedding-ada-002code-search-ada-code-001text-embedding-ada-002code-search-ada-text-001text-embedding-ada-002text-similarity-babbage-001text-embedding-ada-002text-search-babbage-doc-001text-embedding-ada-002text-search-babbage-query-001text-embedding-ada-002code-search-babbage-code-001text-embedding-ada-002code-search-babbage-text-001text-embedding-ada-002text-similarity-curie-001text-embedding-ada-002text-search-curie-doc-001text-embedding-ada-002text-search-curie-query-001text-embedding-ada-002text-similarity-davinci-001text-embedding-ada-002text-search-davinci-doc-001text-embedding-ada-002text-search-davinci-query-001text-embedding-ada-0022. You're trying to use a deprecated OpenAI API endpoint
All Engines API endpoints were deprecated a very, very long time ago.
Change this...
...to this.