1. Introduction
Welcome to the Perplexity API Add-on for Google Sheets! This powerful tool allows you to harness the capabilities of the Perplexity AI directly within your spreadsheets. With this add-on, you can generate text, answer questions, and perform various AI-powered tasks without leaving your Google Sheet.
Benefits:
- Easy access to AI-powered text generation and question-answering
- Customisable settings to fit your specific needs
- Seamless integration with your existing Google Sheets workflows
2. Installation
Follow these simple steps to add the Perplexity API script to your Google Sheet:
- Open your Google Sheet
- Click on "Extensions" in the top menu
- Select "Apps Script"
- Delete any existing code in the script editor
- Copy and paste the entire Perplexity API script into the editor
- Click the disk icon to save the script
- Give your project a name (e.g., "Perplexity API Add-on")
- Close the Apps Script tab
- Refresh your Google Sheet
After refreshing, you should see a new menu item called "Perplexity API" in your Google Sheets top menu.
3. Initial Setup
Before you can start using the add-on, you need to configure your API key:
- Obtain a Perplexity API key:
- Visit the Perplexity AI website
- Sign up or log in to your account
- Navigate to the API section and generate a new API key
- Enter your API key in Google Sheets:
- Click on the "Perplexity API" menu in your Google Sheet
- Select "Configure API Key"
- In the popup window, paste your API key
- Click "OK" to save
Your API key is now securely stored and ready to use with the add-on.
4. Configuring Default Settings
The add-on allows you to customise several settings for optimal use:
Setting the Default Model
- Click on "Perplexity API" > "Set Default Model"
- Choose from the following options:
- llama-3.1-sonar-small-128k-online (Fastest, suitable for simple tasks)
- llama-3.1-sonar-large-128k-online (Balanced speed and capability)
- llama-3.1-sonar-huge-128k-online (Most capable, but slower)
- llama-3.1-8b-instruct (Offline model, faster but less capable)
- llama-3.1-70b-instruct (Offline model, more capable but slower)
- Enter the number corresponding to your choice
- Click "OK" to save
Setting Default Max Tokens
This setting determines the maximum length of the AI's response:
- Click on "Perplexity API" > "Set Default Max Tokens"
- Choose from the following options:
- 100 (Short responses)
- 1000 (Medium-length responses)
- 5000 (Long responses)
- Unlimited (No length limit, but may result in higher API usage)
- Enter the number corresponding to your choice
- Click "OK" to save
Setting Rate Limit
To avoid excessive API usage, you can set a rate limit:
- Click on "Perplexity API" > "Set Rate Limit"
- Enter the maximum number of API calls allowed per minute
- Click "OK" to save
A good starting point is 10 calls per minute, but adjust based on your needs and API plan.
5. Using the PERPLEXITY Function
Now you're ready to use the PERPLEXITY function in your spreadsheet!
Basic Usage
In any cell, type:
=PERPLEXITY(A1)
This will use the content of cell A1 as the prompt for the AI.
Advanced Usage
You can override the default model and max tokens for specific calls:
=PERPLEXITY(A1, "llama-3.1-sonar-large-128k-online", 1000)
This uses the content of A1 as the prompt, specifies the large model, and sets a max token limit of 1000.
Examples
- Simple question answering:
=PERPLEXITY("What is the capital of France?")
- Text generation with a specific model:
=PERPLEXITY(A1, "llama-3.1-sonar-huge-128k-online")
- Long-form content generation:
=PERPLEXITY(B5, "llama-3.1-sonar-large-128k-online", 5000)
6. Understanding the Results
After using the PERPLEXITY function, the cell will display one of the following:
- The AI-generated response to your prompt
- An error message if something went wrong
If you see an error message, refer to the Troubleshooting section below.
7. Troubleshooting
Common issues and solutions:
- "API Key not configured": Make sure you've entered your API key as described in the Initial Setup section.
- "Rate limit exceeded": Wait a minute before making more calls, or increase your rate limit if needed.
- "API returned status [number]": Check the script logs for more details:
- In Google Sheets, go to Extensions > Apps Script
- Click on "Executions" in the left sidebar
- Look for recent executions of the PERPLEXITY function and check their logs
8. Best Practices
- Start with shorter outputs and increase as needed to manage API usage.
- Use cell references for prompts to easily update and reuse them.
- If you're doing many API calls, spread them out over multiple cells to avoid hitting rate limits.
9. Privacy and Security Considerations
Your API key is stored securely in Google's Script Properties and is only used to authenticate API calls to Perplexity. It's not visible to other users of the sheet.
10. Getting Help
If you encounter issues not covered in this guide:
- Check the Perplexity AI documentation for API-specific questions.
- For add-on specific issues, contact email me at tools{@}broadhurst.digital
- For general Google Sheets questions, refer to Google's Sheets Help Center.
Remember, while this add-on is powerful, it interacts with an AI model. Always review the generated content for accuracy and appropriateness before using it for important tasks.
Comments