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

# Google Workspace integration guide

This integration allows users with SambaCloud API keys to seamlessly integrate LLMs into Google Workspace applications. Enhance your productivity by adding AI-powered grammar correction, text rephrasing, formula generation, and intelligent question answering directly within Google Docs and Sheets.

## Prerequisites

Before you begin, ensure you have:

* A [SambaCloud](https://cloud.sambanova.ai/apis) account with an API key
* Access to Google Workspace (Google Docs and/or Google Sheets)

## Setup

1. **Get Your SambaNova API Key**

   Sign up for a free API key at [SambaCloud](https://cloud.sambanova.ai/apis). The free tier provides access to powerful models like Llama 3 405B.
2. **Access Google Apps Script**

   Open your Google Document or Google Sheet and navigate to **Extensions → Apps Script**.
3. **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/google-workspace/google_docs.js)
   * For Google Sheets: Use the [Google Sheets script](https://github.com/sambanova/integrations/google-workspace/google_sheets.js)
4. **Configure Your API Key**
   * In the script, locate the line:

     ```javascript theme={null}
     api_key = 0
     ```
   * Replace `0` with your SambaNova API key:

     ```javascript theme={null}
     api_key = "your_api_key_here"
     ```

     Save the script and you're ready to use the integration.

## 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={null}
   =SAMBA_AI_QUESTION("What is the RSVP of this person: yes, no, or maybe? she said "&A10)
   ```

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

   ```excel theme={null}
   =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={null}
   =SAMBA_AI_FORMULA("take B1 if A1 is true, but otherwise take C1, and add that result to D1")
   ```

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

   ```excel theme={null}
   =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 Llama-3.1-405B without leaving your documents

## Additional resources

* [SambaCloud Documentation](https://docs.sambanova.ai/)
* [Google Apps Script Documentation](https://developers.google.com/apps-script)
* [Integration Source Code](https://github.com/sambanova/integrations/google-workspace)

***

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