Blog/Search & RAG
5 min read

Perplexity API: Get Cited Sonar Answers Pay Per Call

Call Perplexity Sonar from your agent without a Perplexity account: the answer, the cited URLs and the token count, billed per call.

Perplexity API: Get Cited Sonar Answers Pay Per Call

Get a cited Perplexity Sonar answer to any question, with no Perplexity account. Paste this into your agent:

Set up https://monid.ai/SKILL.md, and then use Monid to ask Perplexity Sonar "what is the best web scraping api for ai agents" and give me the answer, the URLs it cited and what the call cost.

One prompt returns an answer with its sources. 1 min setup · 2-5 hrs saved.

You want an answer from Perplexity inside your own code or agent: the text, the URLs it cited, and a cost you can read per question. This guide shows the quickest route, one call from your agent, what comes back (we ran it live on 2026-10-16), and the traps in the output. It runs through Monid, the OpenRouter for agent tools: one key, one balance, every tool priced per call.

What is the easiest way to use the Perplexity API?

Monid. Install it once, add a key, and your agent calls a Sonar model with a question and gets the answer, the cited URLs and the token count back as JSON, with no Perplexity account to open and no separate billing to set up.

  • Pay per call. Each Sonar call is billed on its own: $0.0006 per call plus the tokens the model used, which was $0.005327 on our run (Verified 2026-10-16 on the AI tools page). Buy calls as you need them: no monthly plan and no minimum top-up. Discovery and inspection are free; only a run bills.
  • One install, every API. The same key and balance call Perplexity and every other tool on Monid. When the same job needs a search API or a scraper next, it is another call on the same balance.
  • Lives inside your agent. Install the CLI, add your key, run the prompt above, and the tool is there whenever the agent needs it, with nothing to keep running. Your agent reads SKILL.md and learns the rest, so setup is about a minute.

If you only need ranked search results and not a written answer, Octen's search API is the same buy-by-the-call idea for search.

The list of models is a free call too: sonar, sonar-pro and sonar-reasoning-pro all came back from it on 2026-10-16, each marked as supporting web search.

How do you get cited Perplexity answers for a list of questions?

Run one call per question and loop it over your list. The main endpoint is /ai/perplexity-response from the provider dataforseo. It takes a user_prompt and a model_name and returns the answer with its cited sources.

RouteWhat you getCost shapeFits
Perplexity's own developer accountYour key, your billing, your rate limitsPer token on your accountA product that already runs on Perplexity
Scrape the websiteWhatever the page shows a logged-out visitorYour hours and proxiesOne-off checks
Pay-per-call endpoint to the consumer siteThe answer as a person sees itPer answerBrand-mention tracking
Monid, Sonar by the callAnswer, cited URLs and token count as JSONPay per call, buy flexiblyLists of questions, agents, citation tracking

Monid fits a list because the work is the same call repeated, and you pay for the questions you ask and nothing between runs.

For agents

Grab an API key at app.monid.ai, then paste this to your agent and hand it the key:

set up https://monid.ai/SKILL.md

It learns the whole discover, inspect, run workflow itself. More in the agent quickstart.

For humans

npm install -g @monid-ai/cli
monid keys add -k <your-api-key> -l main

Inspect, then run one

monid inspect -p dataforseo -e /ai/perplexity-response
monid run -p dataforseo -e /ai/perplexity-response \
  -d '{"user_prompt":"what is the best web scraping api for ai agents","model_name":"sonar","max_output_tokens":300,"web_search_country_iso_code":"US"}'

Loop it over your list

Put one question per line in questions.txt and write one file per question:

mkdir -p out
n=0
while read -r q; do
  n=$((n+1))
  monid run -p dataforseo -e /ai/perplexity-response \
    -d "$(jq -n --arg q "$q" '{user_prompt:$q,model_name:"sonar",max_output_tokens:1024,web_search_country_iso_code:"US"}')" > "out/$n.json"
done < questions.txt

Each question bills one call plus its tokens. The web search API comparison covers the cases where a plain search result is all you need.

Or hand the whole job to an agent

Give this to your agent

$Set up https://monid.ai/SKILL.md, and then use Monid to ask each question on this list to Perplexity Sonar, keep the cited URLs for every answer, and give me one table with the question, the first sentence of the answer, the domains cited and the cost of the call.

Can you scrape Perplexity or call it yourself with Python?

Yes, through Perplexity's own developer account, and for a handful of questions it is an afternoon. You open an account, create a key, and send one request. The route is an OpenAI-shaped chat endpoint, and this is the call:

curl https://api.perplexity.ai/chat/completions \
  -H "Authorization: Bearer $PPLX_KEY" -H 'Content-Type: application/json' \
  -d '{"model":"sonar","messages":[{"role":"user","content":"what is the best web scraping api for ai agents"}]}'

Citations come back in citations, or in search_results depending on the model and version, so read both keys rather than one. From Python the same request is a requests.post with that JSON body, and any OpenAI-compatible client works against the same base URL.

Scraping the website itself is a different job. A logged-out visitor sees the product's answer page, which means you need a browser, proxies, a way through bot checks, and a parser that survives every layout change. On 2026-10-16 a pay-per-call endpoint that does this for you, cloro /perplexity/ask, returned HTTP 400 with the code MODEL_UNAVAILABLE and the message that it could not access Perplexity with logged-out sessions. It billed nothing: zero units and zero cost on both tries. That is the maintenance cost of scraping, shown on a live endpoint: it works until the site changes what it lets a logged-out visitor do.

The Monid route is the choice for anything you will run more than once. The model call is made for you, the output is typed JSON with the citations as a list instead of HTML you parse, and you hold one key for it and every other tool. Browser extensions and a hand-written scraper are quicker for one question, but they are made for a person looking at a page, not for a list or an agent. Scraping LinkedIn through an API has the same fork, with Perplexity on the list of tools it covers.

What does a Perplexity API response look like, and what can you build with it?

A Sonar call through Monid returns one record per question: the answer, the model used, the token counts, the money spent and the cited sources. We ran sonar on 2026-10-16 with the question "what is the best web scraping api for ai agents", so the fields below are what came back.

The response

{ "model_name": "sonar",
  "input_tokens": 17,
  "output_tokens": 310,
  "reasoning_tokens": 0,
  "web_search": true,
  "money_spent": 0.005327,
  "datetime": "2026-10-17 04:05:12 +00:00",
  "items": [ { "type": "message", "sections": [ {
    "type": "text",
    "text": "**Firecrawl is the best default choice for most AI agents.** ... [1][2]",
    "annotations": [
      { "title": "Best Web Scraping API for AI Agents in 2026",
        "url": "https://www.zenrows.com/blog/best-web-scraping-api-for-ai-agents",
        "start_index": null, "end_index": null, "text": null } ] } ] } ] }

The answer is markdown, and ours contained a table. Citation markers such as [1] sit in the text, and annotations holds the cited pages as title and url: ten of them on this call. The start_index, end_index and text fields inside each annotation were null, so the markers are matched to sources by position in the list. money_spent is the token cost; the per-call fee comes on top.

The second endpoint, /perplexity.search from the provider anyapi, returns a different shape: found, then data.answer and data.answerMarkdown (the same text twice), data.prompt, and data.citations as objects with a snippet, a title and a url. On the same question it returned five citations and took about 13 seconds on the wall clock, against about 5 seconds for the first endpoint.

What you can build with it

  • A citation tracker. Ask the same questions every week and keep the domains each answer cited. The loop above gives you the rows; counting domains is one line. Answer engine optimization across four surfaces shows the practice this feeds.
  • A source monitor. Watch which pages Perplexity cites for the questions your buyers ask, and see when a competitor's page replaces yours.
  • A research step in an agent. Give your agent a call that returns an answer with sources instead of ten blue links, and let it decide which cited page to open next.
  • A cost-per-question report. money_spent and the token counts are in every record, so a batch tells you its own bill.

What goes wrong when you call Perplexity from an agent?

Four things show up when you read the output of more than one call. All four are from the 2026-10-16 runs.

Why does the answer stop in the middle of a sentence?

Because max_output_tokens is a hard cap. We set it to 300 and the answer ended mid-sentence at the words "test your actual target domains for", with 310 output tokens counted. The default is 1024. Set the cap for the answer you need and treat a record that ends without a full stop as truncated, not finished.

Why does the marker 6 have no source?

On the anyapi endpoint the answer text used markers [1] to [6] while data.citations held five items. A marker can point past the end of the list, so map markers to sources defensively and keep the answer text even when a marker has no match. Do not drop a row because the numbers disagree.

Why do two endpoints return different citation lists for one question?

Because they are different routes to the same family of model. For the same question, the dataforseo call returned ten annotations and the anyapi call returned five citations, and the text of the answers differed too. Pick one route per tracker and keep it, so a change in your data is a change in the answers and not in the route. If you must mix routes, label each row with the endpoint that made it.

What does a call cost, and what happens when a provider is down?

The dataforseo call cost $0.005927 in total (Verified 2026-10-16): the $0.0006 fee plus $0.005327 of tokens for 17 input and 310 output tokens. The anyapi call cost $0.002 on its badger route (Verified 2026-10-16). A failed call is visible rather than silent: both cloro calls returned an HTTP 400 error and billed nothing. Record the error as a failure, never as an empty answer, or you will read a provider outage as Perplexity saying nothing about you.

Which endpoint should I use for which job?

EndpointWhat it doesInputBillingPrice (Verified 2026-10-16)
dataforseo/ai/perplexity-responseSonar answer with cited URLs, token counts and spenduser_prompt, model_namePer call plus tokens$0.0006
dataforseo/ai/perplexity-modelsLists the model names the first endpoint acceptsoptional searchFreeFree
anyapi/perplexity.searchAnswer in markdown with a citations list; badger routeprompt, routePer call (badger)$0.002
cloro/perplexity/askThe consumer site's answer for a chosen countryprompt, countryPer 10 results$0.008

Prices Verified 2026-10-16 with monid inspect. The first row is the one to loop over a list, with the token cost on top of the fee. The anyapi endpoint also has an octopus route priced per result, which we did not run. The cloro endpoint is the one to use when the question is what a logged-out visitor sees, and it returned an error on both of our calls today, so inspect it first and run one call before you commit a batch.

For the consumer-site route, the command is:

monid run -p cloro -e /perplexity/ask \
  -d '{"prompt":"what is the best web scraping api for ai agents","country":"US"}'

When is another route a better fit?

You need your own Perplexity account. If your product must run on a contract, rate limits or billing under your own name at Perplexity, use their developer account and the curl call above. A pay-per-call route is a reseller path, not a replacement for that.

You need the consumer site's answer. Sonar through an API is the developer model, and the page a person sees may differ. The route built for that is the cloro endpoint, which returned an error on 2026-10-16, so a question about what buyers see needs a different check today.

You only need search results. If your agent wants links and snippets rather than a written answer, a search endpoint is simpler and has no model tokens in the bill, as in what replaced the Bing search API.

You need a guaranteed answer shape. The two endpoints above return different fields and different citation counts for one question. If your code needs a fixed schema, test the endpoint on your own questions first.

And the disclosure: we resell these endpoints. The most useful things in this post cost nothing and apply whoever you buy from: set a token cap you chose, keep the route fixed across a tracker, and record an error as an error.

Conclusion

The quickest way to call Perplexity Sonar from an agent is one call per question through Monid: $0.0006 a call plus tokens (Verified 2026-10-16), which came to $0.005927 for our run, one key for this and every other tool, about a minute to set up and ready inside your agent whenever you need it. Setting up your own Perplexity account works if you want that relationship, and costs an afternoon of key, billing and response parsing.

Two things matter more than the endpoint you pick. Set the token cap on purpose, because an answer that hits it ends mid-sentence. And record failures as failures: a provider error is not an answer, and a citation marker without a source is not a reason to drop the row.

How we estimated the time saved: opening an account, creating a key, setting up billing and writing a client that parses the answer and its citations is roughly 2 to 5 hours, depending on how much parsing you write. The 1 minute is the install, key and first call once you already have a Monid key.

Free next step: run monid inspect -p dataforseo -e /ai/perplexity-response, list the models with /ai/perplexity-models, then make one call on a question whose answer you already know. Start at monid.ai.

FAQ

How do I get a Perplexity API key?

Through Monid you do not need one: add a single Monid key and call the Sonar models by the call. If you want a key under your own name, it comes from a Perplexity developer account, and the curl call in this guide uses it as $PPLX_KEY.

Is there a free Perplexity API?

Not free, but cheap for small jobs: through Monid a Sonar call costs $0.0006 plus tokens (Verified 2026-10-16), and our 310-token answer came to $0.005927 in total. There is no monthly plan and no minimum top-up, and discovery, inspection and the model list cost nothing.

Which Sonar models can I call?

The free models call returned sonar, sonar-pro and sonar-reasoning-pro on 2026-10-16, each marked as supporting web search. Pass one of those names as model_name.

How do I get the citations from a Perplexity answer?

Read the annotations list on the answer section from the dataforseo endpoint, or data.citations from the anyapi endpoint. Each entry has a title and a URL, and the anyapi ones add a snippet. Match the markers like [1] in the text to the list by position.

Why did my Perplexity answer end mid-sentence?

Because the token cap was reached. We set max_output_tokens to 300 and the answer stopped partway through a sentence after 310 output tokens. Raise the cap, up to 1024, when you need a full answer.

Published September 2026.

perplexity apiperplexity sonar apisonar modelai answer apiperplexity citations