Packages

A small Perplexity-style web search and answer toolkit for Elixir: swappable search providers, page scraping, and cited answers on any ReqLLM model.

Current section

Files

Jump to
perplexed README.md
Raw

README.md

# Perplexed

[![Hex.pm](https://img.shields.io/hexpm/v/perplexed.svg)](https://hex.pm/packages/perplexed)
[![Hex Docs](https://img.shields.io/badge/hex-docs-blue.svg)](https://hexdocs.pm/perplexed)
[![License](https://img.shields.io/hexpm/l/perplexed.svg)](https://github.com/agoodway/perplexed/blob/main/LICENSE)

A small Perplexity-style web search, scrape and answer toolkit for Elixir.

Perplexed searches the web through a provider you choose, reads the pages it
finds, and turns them into a cited answer on any model
[ReqLLM](https://hex.pm/packages/req_llm) supports.

- **Swappable search** - SearXNG, Firecrawl, Cloudflare Web Search (Ceramic,
  Linkup, Exa) and DeepSeek built in, or any module implementing
  `Perplexed.Search`, alone or as an ordered fallback chain.
- **Page reading** - fetches pages as Markdown, PDFs included, with hosted
  scrapers (DeepSeek, Firecrawl, Cloudflare Browser Run) as cheapest-first
  fallbacks for pages the free tiers cannot read.
- **Cited answers** - plan, search, rank, read and summarize, returning the
  sources used and every result considered.
- **Cost and telemetry** - USD cost on every search, scrape and model call.

## Installation

```elixir
def deps do
  [
    {:perplexed, "~> 0.3.0"}
  ]
end
```

Start Perplexed in your supervision tree with the keys you use:

```elixir
children = [
  {Perplexed,
   firecrawl_api_key: System.fetch_env!("FIRECRAWL_API_KEY"),
   provider: :firecrawl,
   model: "anthropic:claude-haiku-4-5"}
]
```

`answer/2` also needs your model provider's key, configured the way ReqLLM
expects (for example `ANTHROPIC_API_KEY`).

## Quick start

```elixir
# Search the web
{:ok, results} = Perplexed.search("elixir release notes")

# Read a page as Markdown
{:ok, document} = Perplexed.scrape("https://example.com/guide")

# Get an answer with cited sources
{:ok, answer} = Perplexed.answer("When did the first Ferris wheel open?")
```

Search providers and page readers support ordered fallback chains. For example,
use `provider: [:deepseek, :firecrawl]` in your configuration or per call.

PDFs require a module implementing `Perplexed.PdfConverter`, configured with
`pdf_converter: MyApp.PdfConverter`. Set a page budget per call:

```elixir
Perplexed.scrape(url, pdf_max_pages: 20) # Skip PDFs longer than 20 pages
Perplexed.answer(question, pdf_max_pages: 80, pdf_over_limit: :first_pages)
```

The default is unlimited; `pdf_max_pages: nil` overrides an application limit.
See `Perplexed.PdfConverter` for counting and bounded-conversion callbacks.

## Documentation

- [API reference](https://hexdocs.pm/perplexed) — options, return types, and telemetry.

## License

MIT. See [LICENSE](LICENSE).