I am a student who is interested in Flutter and gpt API and developing my Flutter app named 'Fit Buddy'. I want to create a function that connects my own gpt model to the Flutter app via API to send and receive exercise routine information using post and modify it to the appropriate exercise routine based on user response via gpt.
However, during the process of configuring the program, the error message 'invalid_request_error' appeared and the problem that the information processing did not proceed normally from the gpt was confirmed. The schema used in the gpt add action is as follows and the prompt in the flutter app is as follows. Could you tell me what the problem is and how to solve it?
Flutter app prompt example :
prompt: 'model: gpt-3.5-turbo, Exercisetype: leg curl, reps: 15, sets: 3, weight: 40, duration: '15 mins', userInput: 'Gain weight'
Schema for my gpt program:
{
"openapi": "3.0.0",
"info": {
"title": "Fit Buddy User Routine Modulator",
"description": "Generate and revise exercise routines based on user input.",
"version": "1.0.0"
},
"servers": [
{
"url": "https://api.openai.com/v1/engines"
}
],
"paths": {
"/gpt-3.5-turbo/completions": {
"post": {
"operationId": "ReviseExerciseRoutine",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"model": {
"type": "string",
"example": "gpt-3.5-turbo"
},
"prompt": {
"type": "string"
},
`reps...`
},
"required": [
"Exercisetype",
"reps",
"sets",
"weight",
"userInput"
]
}
}
}
},
`responses`
`components / security part`
}
}
}
}
Debug and flutter app tests under various conditions have been conducted, and the codes developed so far are as described above.
You're trying to use the wrong OpenAI API endpoint. All Engines API endpoints were deprecated a very, very long time ago.
Change this...
https://api.openai.com/v1/engines/gpt-3.5-turbo/completions
...to this.
https://api.openai.com/v1/chat/completions
Then, set the model
parameter to gpt-3.5-turbo
. Also, don't forget to set the messages
parameter. Both are required for the Chat Completions API.
See the official OpenAI documentation.