Echo " Error: Unexpected response structure

using open ai api in php script:

<?php // Your OpenAI API key $apiKey = 'xxxxxxxxxxxxx'; // The API URL for GPT-3 (or change the model as needed) $apiUrl = 'https://api.openai.com/v1/completions'; // Data payload for the API request $data = [ 'model' => 'gpt-3.5-turbo-0125', // or the specific model you want to use 'prompt' => 'ga naar chatbase assistant', 'temperature' => 0.7, 'max_tokens' => 60 ]; // Initialize cURL session $curl = curl_init(); // Set cURL options curl_setopt($curl, CURLOPT_URL, $apiUrl); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Authorization: Bearer ' . $apiKey ]); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); // Execute the API request $response = curl_exec($curl); // Close cURL session curl_close($curl); echo "Response from OpenAI: " . trim($decodedResponse['choices'][0]['text']); // Check if the request was successful if ($response) { $decodedResponse = json_decode($response, true); if (isset($decodedResponse['choices'][0]['text'])) { echo "Response from OpenAI: " . trim($decodedResponse['choices'][0]['text']); } else { echo "Error: Unexpected response structure"; } } else { echo "Error: Unable to retrieve response from OpenAI"; } ?>

ends up in

Response from OpenAI: Error: Unexpected response structure