> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sambanova.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Workspace integration guide

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](https://cloud.sambanova.ai/apis) 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

<Steps>
  <Step title="Access Google Apps Script">
    Open your Google Document or Google Sheet and navigate to **Extensions → Apps Script**.
  </Step>

  <Step title="Add the integration script">
    Copy the appropriate JavaScript script for your Google application into the Apps Script editor.

    * For Google Docs: Use the [Google Docs script](https://github.com/sambanova/integrations/blob/main/google_integration/google_docs.js)
    * For Google Sheets: Use the [Google Sheets script](https://github.com/sambanova/integrations/blob/main/google_integration/google_sheets.js)
  </Step>

  <Step title="Configure your API key">
    In the script, locate the line:

    ```javascript theme={}
    api_key = 0
    ```

    Replace `0` with your SambaNova API key:

    ```javascript theme={}
    api_key = "your_api_key_here"
    ```
  </Step>

  <Step title="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:

    ```javascript theme={}
    "model": "Meta-Llama-3.1-405B-Instruct",
    ```

    Replace it with a model that is currently available:

    ```javascript theme={}
    "model": "Meta-Llama-3.3-70B-Instruct",
    ```

    For other options, see [SambaCloud models](/docs/en/models/sambacloud-models).
  </Step>

  <Step title="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.
  </Step>
</Steps>

## 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 features<sup>1</sup>

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:**

   ```excel theme={}
   =SAMBA_AI_QUESTION("What is the RSVP of this person: yes, no, or maybe? she said "&A10)
   ```

   ```excel theme={}
   =SAMBA_AI_QUESTION("Which essay is more compelling? Prompt 1:"&A13&" Prompt 2:"&B13)
   ```

   ```excel theme={}
   =SAMBA_AI_QUESTION("Summarize the following customer feedback: "&B5)
   ```

2. `=SAMBA_AI_FORMULA()`

   Use this function when requesting specific Excel/Sheets formulas from the model.

   **Example Use Cases:**

   ```excel theme={}
   =SAMBA_AI_FORMULA("take B1 if A1 is true, but otherwise take C1, and add that result to D1")
   ```

   ```excel theme={}
   =SAMBA_AI_FORMULA("calculate the percentage change between last month's sales in C2 and this month's sales in C3")
   ```

   ```excel theme={}
   =SAMBA_AI_FORMULA("find the average of all values in column D that correspond to 'approved' status in column E")
   ```

## 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:

```bash theme={}
curl https://api.sambanova.ai/v1/models
```

**`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

* [SambaCloud models](/docs/en/models/sambacloud-models) – Model IDs you can set in the script
* [SambaCloud Documentation](https://docs.sambanova.ai/)
* [Google Apps Script Documentation](https://developers.google.com/apps-script)
* [Integration Source Code](https://github.com/sambanova/integrations/tree/main/google_integration)

***

<sup>1</sup> Inspired by [SheetAI](https://www.sheetai.app/) for the custom function implementation approach.
