A small web search, scrape and research toolkit, in the spirit of Firecrawl or Exa.
search/2runs one web search on a chosen provider and returns aPerplexed.Search.Resultwith the hits and the call's cost. Withscrape: trueit also scrapes each hit's page and attaches thePerplexed.Document.scrape/2turns one URL into Markdown through a configurable ladder of scrapers (seePerplexed.Scrape).batch_scrape/2scrapes several URLs concurrently underPerplexed.TaskSupervisor.answer/2answers a question from the web in fixed steps (plan, search, rank, scrape, summarize) and returns the answer with its sources and every hit considered (seePerplexed.Pipeline).
Search providers and scrapers are adapters (Perplexed.Search,
Perplexed.Scraper), so any of them can be swapped for another built-in
or a custom module. Search and scrape need no model, so they work on their
own as a search engine with optional page contents. Every result carries
its USD cost.
Summary
Types
Every error Perplexed returns: a reason atom (such as :invalid_request,
:authentication, :quota_exhausted, :rate_limited, :upstream,
:transport, :unreadable) and a map of details.
A ReqLLM model spec: "provider:model", a tuple, or a model map or struct.
Functions
Answers query from the web in fixed steps (plan, search, rank, scrape,
summarize) and returns the answer with its sources and every hit
considered. See Perplexed.Pipeline.run/2.
Scrapes URLs concurrently. See Perplexed.Scrape.batch/2.
Child spec that starts Perplexed with settings (see Perplexed.Config).
Add {Perplexed, settings} to the host application's supervision tree;
the settings are cleared when it stops. There is one instance per node.
Scrapes one URL to Markdown. Options are those of Perplexed.Scrape.run/2.
Searches the web for query.
Types
Every error Perplexed returns: a reason atom (such as :invalid_request,
:authentication, :quota_exhausted, :rate_limited, :upstream,
:transport, :unreadable) and a map of details.
A ReqLLM model spec: "provider:model", a tuple, or a model map or struct.
Functions
@spec answer(String.t(), keyword()) :: {:ok, Perplexed.Answer.t()} | {:error, error()}
Answers query from the web in fixed steps (plan, search, rank, scrape,
summarize) and returns the answer with its sources and every hit
considered. See Perplexed.Pipeline.run/2.
@spec batch_scrape([String.t()], keyword()) :: [ {String.t(), Perplexed.Scrape.result()} ]
Scrapes URLs concurrently. See Perplexed.Scrape.batch/2.
@spec child_spec(keyword()) :: Supervisor.child_spec()
Child spec that starts Perplexed with settings (see Perplexed.Config).
Add {Perplexed, settings} to the host application's supervision tree;
the settings are cleared when it stops. There is one instance per node.
The settings are handed over inside a function, so supervisor and crash reports do not print the API keys they carry.
@spec scrape(String.t(), keyword()) :: Perplexed.Scrape.result()
Scrapes one URL to Markdown. Options are those of Perplexed.Scrape.run/2.
@spec search(String.t(), keyword()) :: {:ok, Perplexed.Search.Result.t()} | {:error, error()}
Searches the web for query.
Options
:provider- aPerplexed.Search.spec/0, defaultPerplexed.Search.default_provider/0.:limit- results to return, default 8 (Cloudflare caps it at 10).:scrape- also scrape each hit's page, defaultfalse. A hit whose page could not be read keepsdocument: niland says why inscrape_error.:scrape_options- options forbatch_scrape/2, such as:ladder.
Other options go to the provider.