Google Sheets AI Formula
![Google Sheets AI Formula](/content/images/size/w1200/2024/07/ai--3-.png)
Does Google Sheets have an AI Formula?
No but you can add one.
Simple use Apps Script to add an AI formula to your sheets. You can use your own AI from Open AI and this comes out to be much cheaper than even $20 a month for ChatGPT at times. Depends on your use of AI.
I just updated Better Sheets' AI apps script to use Open AI Omni. Get the full script here.
Can I use ChatGPT in Google Sheets?
No but you can create ChatGPT in Google Sheets.
Let me show you!
But I need help with Google Sheets Formulas
I got you!
Try the AI Formula Generator by Better Sheets. You can enter any thing you want, and the range you're trying to do that to, and it'll figure out a formula for you.
It helps with combining formulas, getting the syntax right, and generally stretching what you can do with Google Sheets.
Go DEEP into AI
Go deeper and wider into how AI can be used in Google Sheets with my course Adventures in AI.
Open AI Formula in Google Sheets
function ai(prompt) {
var apikey = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("apikey").getRange("A1").getValue();
var role = ""
var data = {
"model": "gpt-4o",
"messages": [{"role": "system", "content": role},
{"role": "user", "content": prompt }],
"temperature": 1,
"max_tokens": 500,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
var options = {
'method': 'POST',
'contentType': 'application/json',
'headers': {
'Authorization' : 'Bearer ' + apikey
},
'payload': JSON.stringify(data)
}
var answer = UrlFetchApp.fetch("https://api.openai.com/v1/chat/completions",options)
var response = answer.getContentText()
var json = JSON.parse(response)
return json.choices[0].message.content
}