PHP CURL Openai Remove Quotes from Post Data

Having a hard time getting PHP Curl to work with your post data? I damn near drove me to drinking :)

So, you have something like this after using $openaiTemp = $_POST[openaiTemp];

 $postData = [
  'model' => $openaiModel,
  'prompt' => $openaiModel,
  'temperature' => "0.7",
  'max_tokens => "2150",
  'top_p' => "1",

Those pesky double quotes are wrecking the array.

There are a couple of ways to fix the issue.

One:

$postData['temperature'] = (float) $postData['temperature'];
$postData['max_tokens'] = (int) $postData['max_tokens'];

Two:

 $postData = [
  'model' => $openaiModel,
  'prompt' => $openaiPrompt,
  'temperature' => (float) $openaiTemp,
  'max_tokens => (int) $openaiTokens,
  'top_p' => "1",

This worked out well for me. Hope it helps you.