Migrate from Perplexity

Keep the Perplexity SDK for the Search API. Change the base URL and the key.

typesearch speaks Perplexity’s Search API (POST /search) — the ranked results, not Sonar’s generated answers. With the official SDK, migrating is one line.

from perplexity import Perplexity

# before: client = Perplexity()
client = Perplexity(api_key=TYPESEARCH_API_KEY, base_url="https://api.typesearch.ai/compat/perplexity")

r = client.search.create(query=["el dólar", "el FMI"], max_results=5, search_recency_filter="week")

You can also set PERPLEXITY_BASE_URL instead of changing code.

Parameters

PerplexityOn typesearch
query (one, or up to 5)Same. Several queries are judged together; results come in one list.
max_results (1–20)Same.
search_domain_filterSame: without a prefix it includes, with - it excludes, paths included. Mixing both is an error, as on Perplexity.
search_recency_filterhour, day, week, month, year.
search_after_date_filter, search_before_date_filterSame (MM/DD/YYYY). last_updated_* is read as the publication date (approximated:).
country, search_language_filterIgnored unless Argentina and Spanish, the current coverage.
max_tokens, max_tokens_per_page, search_context_sizeIgnored: excerpts are always short.
search_type: "people"An error: the index is news.

Without a date filter it searches the whole index, as Perplexity does, in fast mode.

Our extras

With the Perplexity SDK, send them through extra_body:

r = client.search.create(query="el dólar", extra_body={"typesearch": {"tone": True, "mode": "normal"}})

They come back in a typesearch field of the response. Errors keep Perplexity’s format: 422 with detail[] for validation, error for the rest.

On this page