<?xml version="1.0" encoding="UTF-8"?><oembed><type>video</type><version>1.0</version><html>&lt;iframe src=&quot;https://www.loom.com/embed/a1ffe7fabcf8467a9a17ffef92602108&quot; frameborder=&quot;0&quot; width=&quot;1280&quot; height=&quot;960&quot; webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;</html><height>960</height><width>1280</width><provider_name>Loom</provider_name><provider_url>https://www.loom.com</provider_url><thumbnail_height>960</thumbnail_height><thumbnail_width>1280</thumbnail_width><thumbnail_url>https://cdn.loom.com/sessions/thumbnails/a1ffe7fabcf8467a9a17ffef92602108-00001.gif</thumbnail_url><duration>126.772</duration><title>GPTs in Sheets Using our Script</title><description>Below is our script for you to copy and paste:

// The two functions used in cell references are defined below
// A cell with =GPT(A2) will return contents in cell A2 using faster gpt-3.5-turbo
// and a cell with =GPT4(A2) in a cell will do the same but using the more powerful gpt-4 model.

function GPT(input) {
  return gptCommon(input, &quot;gpt-3.5-turbo&quot;);
}

function GPT4(input) {
  return gptCommon(input, &quot;gpt-4&quot;);
}


// common function dealing with the aip calls using the model needed
function gptCommon(input, model) {
  const GPT_API = &quot;YOUR-OPEN-AI-API-KEY&quot;; //your Open AI API key goes here.
  const BASE_URL = &quot;https://api.openai.com/v1/chat/completions&quot;;

  const headers = {
    &quot;Content-Type&quot;: &quot;application/json&quot;,
    &quot;Authorization&quot;: `Bearer ${GPT_API}`
  };

  const options = {
    method: &quot;POST&quot;, // GET also works
    muteHttpExceptions: true,
    headers: headers,
    payload: JSON.stringify({
      model: model,
      messages: [
        { &quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;&quot; },
        { &quot;role&quot;: &quot;user&quot;, &quot;content&quot;: input }
      ],
      temperature: 0.2  // value between 0 and 1 think of it like 0 very conservative and 1 excentric for B2B we suggest 0.2.
    })
  };

  const response = JSON.parse(UrlFetchApp.fetch(BASE_URL, options));
  console.log(response.choices[0].message.content);
  return response.choices[0].message.content;
}</description></oembed>