Skip to main content

Perplexity AI Integration with SmythOS

Want to build agents with access to real-time web knowledge? Connect Perplexity AI to SmythOS and empower them with conversational search models that provide up-to-date, sourced answers.

TL;DR

Securely link your Perplexity AI account to SmythOS using an API key. Then, use the "Chat Completion" component to run a variety of powerful language models, including online models that can browse the web.

List of Perplexity AI Components

The Perplexity AI integration provides a single, powerful component for accessing their suite of language models.

ComponentActionWhat it DoesInputsKey OutputsUse Case
Chat CompletionAI TaskRuns chat and text generation on various models, including web-connected ones.required prompt
optional model
message_contentResearch, fact-checking, content creation.
INFO
Why Integrate Perplexity AI with Your Agent?

Perplexity AI specializes in providing accurate, sourced information through conversational search. Integrating it with SmythOS allows you to build agents that are not just creative, but also factual and current.

  • Real-Time, Web-Connected Answers: Use "online" models (e.g., llama-3-sonar-large-32k-online) to give your agents the ability to browse the internet to answer questions about recent events or topics.
  • Factual and Sourced Information: Perplexity's models are optimized to provide answers with citations, making them ideal for research, fact-checking, and creating trustworthy content.
  • Powerful Conversational AI: Leverage state-of-the-art Llama 3 and Mixtral models for a wide range of NLP tasks, from drafting emails to complex problem-solving.
  • Optimized for Cost and Speed: Choose from a range of models, from the fast and efficient Sonar Small to the powerful Sonar Large, allowing you to pick the right tool for any task and budget.

Prerequisites

Before you begin, please ensure you have the following:

  • An active SmythOS account. (Sign up here).
  • A Perplexity AI account.
  • Your Perplexity AI API Key.

Getting Started With Perplexity AI

The connection between SmythOS and Perplexity AI is configured using a secure API key.

Step 1: Get Your Perplexity AI API Key

  1. Log in to your Perplexity AI account.
  2. Navigate to your account settings and click on the API section, or go directly to https://www.perplexity.ai/settings/api.
  3. Click Generate to create a new API key.
  4. Copy the key to your clipboard.

Step 2: Store Your API Key in SmythOS Vault

Your API Key is a sensitive credential. Use the SmythOS Vault to store it securely.

  1. In your SmythOS dashboard, navigate to the Vault.
  2. Create a new secret and paste your Perplexity AI API Key as the value. Give it a memorable name, like perplexity_api_key.
  3. For more details, see the Vault Documentation.

Step 3: Configure the Perplexity AI Component

  1. In your SmythOS agent graph, drag and drop the Perplexity AI Chat Completion component.
  2. Click the component to open its Settings panel.
  3. In the API Key field, select the secret you saved in the Vault (e.g., perplexity_api_key).
  4. Select your desired Model from the dropdown list.
  5. Your connection is now configured for that component.
Heads-up
You must add the API Key from the Vault to each Perplexity AI component you use. This ensures all your API calls are properly authenticated.

Which Perplexity AI Model Should I Use?

If you need to…Task TypeRecommended Model (Example)Why this one?
Answer questions about recent eventsReal-time Searchllama-3-sonar-large-32k-onlineProvides the best reasoning with live web access.
Perform a quick, cost-effective taskGeneral Purposellama-3-sonar-small-32k-chatA fast and efficient model for standard NLP tasks.
Write high-quality, creative contentCreative Writingllama-3-70b-instructA powerful instruction-tuned model for creative and complex generation.
Balance performance and costBalancedmixtral-8x7b-instructA strong mixture-of-experts model with excellent performance for its cost.
TIP

The "online" models are unique to Perplexity and can access the internet. The "instruct" models are fine-tuned for following commands.

Component Details

This section provides detailed information for the Perplexity AI component.

Chat Completion

Provides a unified interface to send prompts to Perplexity's suite of powerful and web-connected language models.

INFO
This component requires an API Key for authentication, as detailed in the Getting Started section.

Component-Specific Settings

  • Model: Choose your desired AI model from the dropdown list in the settings panel. Options range from fast, small models to large, web-connected ones.

Inputs

FieldTypeRequiredNotes
promptstringYesThe text input, question, or instruction to send to the language model.

Outputs

FieldTypeDescription
message_contentstringThe text content of the AI's generated response.
idstringThe unique identifier for the chat completion request.
ResponseobjectThe full, raw JSON response from the Perplexity AI API, including usage data.
HeadersobjectThe HTTP headers from the API response.
Use Case

Create a "Fact-Checker" agent. The agent takes a statement as a prompt, sends it to the llama-3-sonar-large-32k-online model, and asks it to "Verify this statement and provide sources." The agent can then parse the sourced response to confirm the statement's accuracy.

{
"component": "perplexityai.chatCompletion",
"prompt": "What were the main announcements from the latest Apple event?",
"model": "llama-3-sonar-large-32k-online"
}
Model Costs and Capabilities

The different Perplexity models have varying costs and capabilities. "Online" models are great for current events but may be more expensive. Choose the model that best fits your task and budget.

Best Practices & Advanced Tips

  • Secure Your API Key: Always use the SmythOS Vault to store your Perplexity AI API key.
  • Choose the Right Model: The key to this integration is model selection. Use "online" models for questions that require up-to-date information. Use "chat" or "instruct" models for creative tasks, summarization, or general conversation where live web access isn't needed.
  • Craft Clear Prompts: For the best results, especially with "online" models, frame your prompt as a clear question or instruction. This helps the model understand when and how to search the web.
  • Check the Response for Sources: When using an "online" model, the full Response object may contain a list of sources the model used to generate the answer. You can parse this for fact-checking and citation.

Troubleshooting Common Issues

  • Error: 401 Unauthorized

    • Cause: The API key is missing, invalid, or disabled.
    • Solution: Verify that the API key in your SmythOS Vault is correct and matches the one in your Perplexity AI dashboard.
  • Error: 402 Payment Required

    • Cause: You may have exceeded your plan's limits or have a billing issue with your Perplexity AI account.
    • Solution: Check your account status and billing information on the Perplexity AI website.
  • Error: 404 Not Found

    • Cause: This can happen if the API endpoint is incorrect or the specified model name is not valid.
    • Solution: Ensure you have selected a valid model from the component's dropdown list. If the issue persists, check Perplexity's API documentation for any recent changes.
  • Error: 429 Too Many Requests

    • Cause: You have exceeded the rate limit for your Perplexity AI account or for the specific model you are using.
    • Solution: Add a delay in your agent between frequent calls. Check the Perplexity API documentation for specific rate limit information.

What's Next?

You are now ready to build intelligent, fact-aware agents with the SmythOS Perplexity AI Integration!

Consider these ideas:

  • Build an Agent That...

    • Acts as a research assistant. It takes a topic, uses an "online" model to gather sourced information, and then uses a standard "chat" model to format that information into a structured report.
    • Monitors social media for questions about your product. When a question is found, the agent uses an "online" model to search your public documentation or recent blog posts to find the answer and drafts a reply.
    • Creates daily news summaries. Every morning, the agent asks an "online" model, "What are the top 3 headlines in the tech industry today?" and sends the summary to a Slack channel.
  • Explore Other Integrations:

    • Combine Perplexity AI with a text-to-speech service like Elevenlabs to create an audio news briefing.
    • Use Perplexity to research a topic, then use the Fal.ai Integration to generate a relevant image for the content.
    • Feed the output from Perplexity into a Google Sheet to build a repository of sourced facts and research.