openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.56k stars 465 forks source link

Fixing CreateResponseChoice text option for GPT4 #396

Closed Dlas1212 closed 3 weeks ago

Dlas1212 commented 1 month ago

Updating CreateResponseChoice to support gpt-4o model's responses

What:

Description:

Using the new GPT 4o model, you can't use the completion()->createStreamed() method since response is now different.

A) The base API Url needs to be manually set to https://api.openai.com/v1/chat when declaring a new client. B) The response from the completion includes "choices", but using GPT-4o model the text result now comes from $attributes['delta']['content'] instead of $attributes['test']

gehrisandro commented 3 weeks ago

Hi @Dlas1212

The completions() endpoint is outdated and you have to use the chat() endpoint now. See: https://platform.openai.com/docs/api-reference/completions