TutorialPractitioner7 min read

Perplexity Agent API and Search API for marketers

When marketers should use the Perplexity Agent API or Search API, what they cost, how filters work, and a starter script for citation checks.

Dipuck Jones
Written by Founder of MentionX · 13+ years in B2B SaaS growth and SEO
Reviewed
Short answer

Perplexity has two APIs that matter to marketers. The Agent API (`POST https://api.perplexity.ai/v1/agent`) returns a written answer with citations, using effort levels from fast to ultra-preview. It replaced the Sonar API, whose support ended on 27 September 2026. The Search API (`POST https://api.perplexity.ai/search`) returns ranked web results with no generated answer, for $5 per 1,000 requests. Use the Agent API to sample answers, and the Search API to see which pages rank for a query.

Key takeaways
  • Agent API: answers plus citations. Choose an effort level, and pin a version for tracking stability.
  • Search API: ranked results (title, URL, snippet, date), up to 20 per query and up to 5 queries per request.
  • Filters (domain, recency, country or location, language) make research repeatable.
  • API answers aren't identical to the consumer app, so use them as a consistent sample, not ground truth.

Checked 5 November 2026 (CET) against the Perplexity Help Center, Perplexity blog, Perplexity API docs and the outlets cited in Sources. Perplexity renames and moves features often, so confirm labels and limits in your own account. "Our view" marks MentionX opinion. Ledgerline is a fictional company used for illustration.

01Which API do you need?

JobAPIWhy
"Which brands does Perplexity mention for this buyer question?"Agent APIYou need the written answer and its citations
"Which pages rank for this query in Perplexity's index?"Search APIRanked results, cheaper and faster
Daily news monitoring for competitorsSearch API with a recency filterResults only, easy to diff
Research summaries in a workflowAgent API, low or mediumMulti-step research with citations
Large overnight jobsAgent API BatchLower-priority, bulk processing

02How does the Agent API work?

You send an input and an effort level. Perplexity bundles a model, search configuration, tools and a system prompt for each effort level.

Effort levelGood at (Perplexity's description, paraphrased)
fastSingle facts and short summaries with citations
lowEveryday research with light multi-step lookups
mediumMulti-hop browsing across many sources
highExhaustive, source-heavy research
xhighOpen-ended agentic work, including code in a sandbox
ultra-previewBroadest coverage, with long runs

Two settings matter for tracking:

  • Pinning. effort="fast" follows Perplexity's latest configuration. effort="fast@2026-10-16.0" (an example version) stays fixed, which keeps month-on-month comparisons fair.
  • `reasoning.effort` is separate. It controls the model's reasoning, not the effort level.

If you are migrating from Sonar, Perplexity's guide maps sonar and sonar-pro to fast, sonar-reasoning-pro to low, and sonar-deep-research to high. Check the migration page for your exact case.

Starter script

# pip install perplexityai ; set PERPLEXITY_API_KEY in your environment
from perplexity import Perplexity

client = Perplexity()

response = client.responses.create(
    effort="fast",
    input="What are the best accounts payable automation tools for mid-market companies?",
)

print(response.output_text)

The response also includes the sources used. Log both the text and the cited URLs for each prompt.

03What does the Agent API cost?

You pay for model tokens plus tool calls. Published tool prices (Nov 2026):

ToolPrice
web_search$2.50 per 1,000 calls, or $1.00 per 1,000 with search_type: "fast"
fetch_url$0.0005 per call
People or finance search$0.005 per call
Code sandbox$0.03 per session (check the docs for the unit)

The fast to xhigh effort levels default to fast search. Check the pricing page before budgeting, because model token prices vary by underlying model.

04How do web_search filters work?

Inside the web_search tool you can add:

FilterWhat it does
search_domain_filterInclude up to 20 domains, or exclude them with a - prefix. Use one mode, not both
search_recency_filterhour, day, week, month or year
user_locationCountry, region, city and coordinates
Token budgetsmax_tokens and max_tokens_per_page to limit search context
response = client.responses.create(
    effort="low",
    input="What changed in Competitor A's pricing this month?",
    tools=[{
        "type": "web_search",
        "filters": {
            "search_domain_filter": ["competitor-a.example"],
            "search_recency_filter": "month"
        }
    }],
)

05How does the Search API work?

from perplexity import Perplexity

client = Perplexity()

search = client.search.create(
    query=["accounts payable automation software", "duplicate invoice detection"],
    max_results=10,
    country="US",
)

for result in search.results:
    print(result.title, result.url)

Key facts:

  • Price: $5 per 1,000 requests. A request with several queries (up to five) is billed as one request but counts once per query against rate limits.
  • Results: 1-20 per query (default 10), with title, URL, snippet and date.
  • Filters: domain, recency or date range, country and language.
  • Architecture: Perplexity says the index covers more than 200 billion URLs and ranks sub-document spans, not just whole pages (lesson 13).

06What else is in the platform?

  • Batch API for bulk Agent requests.
  • Background mode for long-running requests.
  • MCP server to use Perplexity search from tools such as Claude or Cursor.
  • Cookbook examples, including news monitors and domain filtering patterns.

07How do you keep API work safe and cheap?

  • Store keys in a secret manager or environment variable. Never paste them into sheets, docs or prompts.
  • Set spend alerts in the API console.
  • Log everything: prompt, effort level and version, date, answer, citations and cost.
  • Respect rate limits. Back off on 429 errors.
  • Sample, don't scrape. A focused prompt set run weekly beats thousands of random queries.

08Worked example: Ledgerline

Ledgerline is a fictional accounts-payable software company. Details are illustrative.

Ledgerline's analyst set up a weekly job for 40 buyer prompts.

ComponentChoice
Answer samplingAgent API, fast effort pinned to one version, 40 prompts weekly
Ranking checkSearch API, the same 40 queries, US, top 10
LoggingOne row per prompt per week: answer, cited URLs, brands mentioned, cost
CostA few dollars a month at this volume (check against your own token usage)
ReviewMonthly, in the AI visibility report (lesson 19)

Walkthrough

  1. Created an API key and stored it in the team's secret manager.
  2. Ran the starter script for 5 prompts to check output and cost.
  3. Pinned the effort version for comparability.
  4. Added the Search API run for the same queries.
  5. Wrote results to a sheet, then later moved the job to n8n.
  6. Recorded the version change whenever they re-pinned.

09Common mistakes

  • Treating API answers as what every user sees. They're a sample.
  • Not pinning. Silent configuration changes break trends.
  • Mixing include and exclude in the domain filter. Use one mode.
  • Keys in spreadsheets. Use a secret store.

10Try it yourself

Install the SDK, run the starter script for three of your buyer prompts, and log brands mentioned and cited URLs. Then run the same three as Search API queries. Compare which of your pages appear in each.

11Quick quiz

1. What replaced the Sonar API?

Answer: The Agent API, with effort levels.

2. What does the Search API return?

Answer: Ranked results with title, URL, snippet and date, but no generated answer.

3. Why pin an effort version?

Answer: To keep tracking comparable over time.

12What should you check before the next lesson?

  • The API key is stored safely and spend alerts are set.
  • A five-prompt test is logged with answers, citations and cost.
  • You've decided on dynamic or pinned effort.

Previous: The Comet browser. Next: Automate Perplexity research with n8n. Or return to the Perplexity for Marketers track. Related: Share of citations tracking, Build your own AI visibility tracker with APIs.

13Common questions

What happened to the Sonar API? Perplexity ended Sonar support on 27 September 2026 and moved developers to the Agent API, which uses effort levels such as fast, low and high instead of Sonar model names.

Does the API give the same answer as perplexity.ai? Not exactly. The API and the consumer app use different configurations, so treat API results as a consistent sample rather than a copy of what a given user sees.

Do I need a developer? For a first test, no. The quickstart takes minutes. For a scheduled tracking job, involve someone who can manage keys, logging and costs, or use n8n.

Questions people ask

3 answers

What happened to the Sonar API?

Perplexity ended Sonar support on 27 September 2026 and moved developers to the Agent API, which uses effort levels such as fast, low and high instead of Sonar model names.

Does the API give the same answer as perplexity.ai?

Not exactly. The API and the consumer app use different configurations, so treat API results as a consistent sample rather than a copy of what a given user sees.

Do I need a developer?

For a first test, no. The quickstart takes minutes. For a scheduled tracking job, involve someone who can manage keys, logging and costs, or use n8n.

Sources

  1. Perplexity API docs, Agent API quickstartdocs.perplexity.ai
  2. Perplexity API docs, Effort levelsdocs.perplexity.ai
  3. Perplexity API docs, Web search tooldocs.perplexity.ai
  4. Perplexity API docs, Migrate from Sonardocs.perplexity.ai
  5. Perplexity API docs, Search API quickstartdocs.perplexity.ai
  6. Perplexity API docs, Pricingdocs.perplexity.ai
  7. Perplexity blog, Architecting and Evaluating an AI-First Search APIperplexity.ai
  8. All accessed 5 Nov 2026.
Written and reviewed by Dipuck JonesHow we research and testReport an error

Keep learning

All Perplexity →