Skip to main content
This article shows you how to add AI-powered writing and data tools to Google Docs and Google Sheets using SambaNova models, directly from your existing Google Workspace with no additional software required. You can add grammar correction, text rephrasing, formula generation, and intelligent question answering without leaving your documents and spreadsheets.

Prerequisites

Before you begin, ensure you have:
  • A SambaCloud account with an active API key. The free tier provides access to models like Meta-Llama-3.3-70B-Instruct.
  • Access to Google Workspace (Google Docs and/or Google Sheets)
  • Script execution permissions enabled on your Google Workspace account. If you are on a managed Workspace plan, confirm with your administrator that Apps Script is allowed.

Setup

1

Access Google Apps Script

Open your Google Document or Google Sheet and navigate to Extensions → Apps Script.
2

Add the integration script

Copy the appropriate JavaScript script for your Google application into the Apps Script editor.
3

Configure your API key

In the script, locate the line:
Replace 0 with your SambaNova API key:
4

Update the model

Both scripts currently request Meta-Llama-3.1-405B-Instruct, which was removed from SambaCloud on 6/25/2025. Until the scripts are updated, change it yourself or every request fails.In the script, locate the line:
Replace it with a model that is currently available:
For other options, see SambaCloud models.
5

Save and reload

Click Save project (floppy disk icon) in the Apps Script editor, then reload your Google Doc or Sheet. The SambaAI menu appears in the menu bar after the page reloads.

Google Docs features

Once configured, you’ll have access to AI-powered text editing tools through the SambaAI menu.

Clean grammar

  1. Highlight any text in your document
  2. Navigate to SambaAI → Clean Grammar
  3. The selected text will be automatically corrected for grammar issues in place

Rephrase text

  1. Highlight the text you want to rephrase
  2. Navigate to SambaAI → Rephrase
  3. A new paragraph with a concise and professional rephrasing will be appended below your selection

Google Sheets features1

The integration provides two custom functions for use in your spreadsheets:
  1. =SAMBA_AI_QUESTION() Use this function for general AI queries and text analysis. Example Use Cases:
  2. =SAMBA_AI_FORMULA() Use this function when requesting specific Excel/Sheets formulas from the model. Example Use Cases:

Benefits

By integrating SambaNova with Google Workspace, you can:
  • Improve writing quality with instant grammar corrections and professional rephrasing
  • Automate formula creation by describing what you need in plain English
  • Analyze data intelligently with natural language queries directly in your spreadsheets
  • Boost productivity by reducing context switching between applications
  • Leverage state-of-the-art models like Meta-Llama-3.3-70B-Instruct without leaving your documents

Troubleshooting

Every SambaAI action fails, or a model error is returned. The script is still requesting Meta-Llama-3.1-405B-Instruct, which was removed from SambaCloud on 6/25/2025 and moved to SambaStack only. Set the "model" line to a currently available ID as described in setup step 4. You can check what is live at any time with the following, which needs no API key:
401 or an authentication error. The api_key line is still 0, or the key is quoted incorrectly. It must be a quoted string, as in api_key = "your_api_key_here", not a bare value. The SambaAI menu does not appear in Docs or Sheets. Reload the document after saving the script. If it still does not appear, script execution is likely blocked on your Workspace plan. Confirm with your administrator that Apps Script is allowed. Custom functions return an error in Sheets. =SAMBA_AI_QUESTION() and =SAMBA_AI_FORMULA() only exist in the Sheets script. Copying the Docs script into a spreadsheet defines the SambaAI menu but not these functions.

Additional resources


1 Inspired by SheetAI for the custom function implementation approach.