Skip to main content

Perplexity Integration

Perform web searches and leverage Perplexity's advanced LLM models for real-time information retrieval.


Timbal integrates with Perplexity to provide advanced search and LLM capabilities.

This integration allows you to perform web searches and leverage Perplexity's models directly within your Timbal workflows.

Prerequisites

Before using the Perplexity integration, you'll need:

  1. A Perplexity API key – Get your API key here
  2. Store your obtained API key in an environment variable named PERPLEXITY_API_KEY to facilitate its use by the tools.

Description

The search step allows you to perform a web search or interact with Perplexity's LLMs using a variety of parameters for customization.

Example

from timbal.steps.perplexity import search
result = await search(query="What is the capital of France?")

Parameters

ParameterTypeDescriptionRequired
querystrQuery to search for.Yes
modelstrModel to use. Default: sonar.No
system_promptstrSystem prompt to guide the LLM's behavior and role.No
temperaturefloatAmount of randomness in the response. Ranges from 0 to 2. Default: 0.2No
top_pfloatNucleus sampling threshold. Ranges from 0 to 1. Default: 0.9No
search_domain_filterlist/NoneLimit citations to specific domains. Only available in certain tiers.No
return_imagesboolWhether to return images in the response. Only available in certain tiers.No
return_related_questionsboolWhether to return related questions. Only available in certain tiers.No
search_recency_filterLiteral['month', 'week', 'day', 'hour']Restrict search results to a recent time interval.No
top_kintNumber of tokens to keep for top-k filtering. 0 disables.No
streamboolWhether to stream the response.No
presence_penaltyfloatPenalize new tokens based on presence. Ranges from -2.0 to 2.0.No
frequency_penaltyfloatPenalize new tokens based on frequency. >1.0 discourages repetition.No
response_formatdict/NoneEnable structured outputs with a JSON or Regex schema.No

Agent Integration Example

from timbal.steps.perplexity import search
from timbal import Agent
agent = Agent(
tools=[search]
)
response = await agent.complete(prompt="What are the latest AI trends?")

Notes