$model, 'messages' => [ [ 'role' => 'system', 'content' => $system_message ], [ 'role' => 'user', 'content' => "$user_message\n\n$content" ] ], 'temperature' => $temperature, 'max_tokens' => $max_tokens ]; // Send the request to the API $response = wp_remote_post($endpoint, [ 'headers' => [ 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json' ], 'body' => wp_json_encode($data) ]); if (is_wp_error($response)) { return 'Error connecting to AI service.'; } $body = json_decode(wp_remote_retrieve_body($response), true); $markdown_text = isset($body['choices'][0]['message']['content']) ? $body['choices'][0]['message']['content'] : 'No suggestions available.'; // Parse Markdown to HTML $Parsedown = new AiCustomParsedown(); $html_output = $Parsedown->text($markdown_text); return $html_output; }