I’m building a mobile app with Flutter and integrated the ChatGPT API for my chatbot feature. The responses work fine but I’m getting really frustrated with how long it takes to receive answers. Sometimes it’s taking like 45 seconds or even a full minute just to get a simple response back from the API.
Here’s my current implementation:
Future<String> fetchAIResponse(String userInput) async {
OpenAI.apiKey = myApiKey;
try {
final completion = await OpenAI.instance.chat.create(
model: 'gpt-3.5-turbo',
messages: [
OpenAIChatCompletionChoiceMessageModel(
content: userInput,
role: OpenAIChatMessageRole.user,
),
],
);
return completion.choices.first.message.content;
} catch (error) {
return "Error occurred, please retry.";
}
}
I’m currently using the free tier account. Could this be why responses are so sluggish? Would upgrading to a premium plan actually speed things up or is there something wrong with how I’m calling the API?