AI visibility

Perplexity API answer with citations

POST/perplexity-api-answer
from $0.002/calljson responserest · mcp
01// about this endpoint

Asks a Perplexity model through its API (not the consumer app) and returns its answer with citations: the `result[0].items[]` element with `type: "message"` holds the answer in `sections[].text` and its citations in `sections[].annotations[]` (each with `url` and `title`). Token counts are on `result[0]`. Numbers measured this way are API answers, which can differ from what the Perplexity app shows. A live answer can take up to 95 seconds; one that runs longer fails with an error and is not charged. An answer with no sources is a valid answer, not an error.

02// code samples

Call it over REST

Authenticate with a bearer token against https://api.superagnt.com. Swap the placeholders for your key and parameter values.

curlbash
curl -s -X POST "https://api.superagnt.com/perplexity-api-answer" \
  -H "Authorization: Bearer <YOUR_AGNTDATA_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{ "user_prompt": "<string>" }'
03// give it to your agent

Copy-paste prompt

Paste this into a coding agent. It connects the superagnt MCP server, finds the tool data_seo_perplexity_api_answer, and runs a first call — with the REST fallback if MCP is unavailable.

agent prompttext
You are wiring up the superagnt_ "SEO" API to use this endpoint: Perplexity API answer with citations.

1. CONNECT over MCP (preferred). No token to paste either way.
   On Claude (claude.ai, the desktop app, or Claude Code signed in with a Claude
   account), the server is a connector: give the user this link, they click Add
   and approve:
     https://claude.ai/customize/connectors/yours?modal=add-custom-connector&connectorName=superagnt&connectorUrl=https%3A%2F%2Fmcp.superagnt.com%2Fmcp&open_in_browser=1
   Any other MCP client (or Claude Code signed in with an API key): add the server
   and let the client run the browser sign-in:
     claude mcp add --scope user --transport http superagnt https://mcp.superagnt.com/mcp
     claude mcp login superagnt
   MCP endpoint: https://mcp.superagnt.com/mcp
   After connecting, the tool you want is named exactly:
     data_seo_perplexity_api_answer
   Call agnt_tools_search or agnt_tools_list_enabled to confirm it is available.

2. REST fallback (if you are not using MCP):
     POST https://api.superagnt.com/perplexity-api-answer
     Header: Authorization: Bearer <YOUR_AGNTDATA_API_KEY>
   Required parameters:
    - user_prompt (string, required) — The question to ask the model.
   Optional parameters:
    - model_name (string, optional) — The model to ask: sonar, sonar-pro (default sonar).
    - max_output_tokens (integer, optional) — Cap on the answer's length in tokens, 16-2048 (default 1024). Web search can push a model slightly past it.
    - web_search_country_iso_code (string, optional) — Two-letter country code the web search runs from, e.g. 'US'. Sonar models always search the web.

3. COST & KEY. This endpoint is metered — pricing varies by request, from $0.002 per call. Only successful calls are charged.
   Get a superagnt_ API key at https://app.superagnt.com.

4. TEST. Connect the server (or set the key), discover the tool
   (data_seo_perplexity_api_answer), run one minimal call with just the required parameters,
   and report back the shape of the JSON response (top-level fields).

Reference (machine-readable variant): https://www.superagnt.com/docs/apis/seo/endpoints/perplexity_api_answer.md
mcp tool definitionjson
{
  "name": "perplexity_api_answer",
  "description": "Asks a Perplexity model through its API (not the consumer app) and returns its answer with citations: the `result[0].items[]` element with `type: \"message\"` holds the answer in `sections[].text` and its citations in `sections[].annotations[]` (each with `url` and `title`). Token counts are on `result[0]`. Numbers measured this way are API answers, which can differ from what the Perplexity app shows. A live answer can take up to 95 seconds; one that runs longer fails with an error and is not charged. An answer with no sources is a valid answer, not an error.",
  "parameters": {
    "type": "object",
    "properties": {
      "user_prompt": {
        "type": "string",
        "maxLength": 500,
        "description": "The question to ask the model."
      },
      "model_name": {
        "type": "string",
        "enum": [
          "sonar",
          "sonar-pro"
        ],
        "default": "sonar",
        "description": "The model to ask: sonar, sonar-pro (default sonar)."
      },
      "max_output_tokens": {
        "type": "integer",
        "minimum": 16,
        "maximum": 2048,
        "default": 1024,
        "description": "Cap on the answer's length in tokens, 16-2048 (default 1024). Web search can push a model slightly past it."
      },
      "web_search_country_iso_code": {
        "type": "string",
        "description": "Two-letter country code the web search runs from, e.g. 'US'. Sonar models always search the web."
      }
    },
    "required": [
      "user_prompt"
    ]
  }
}
04// parameters
NameInTypeRequiredDescription
user_promptbodystringrequiredThe question to ask the model.
model_namebodystringoptionalThe model to ask: sonar, sonar-pro (default sonar).
max_output_tokensbodyintegeroptionalCap on the answer's length in tokens, 16-2048 (default 1024). Web search can push a model slightly past it.
web_search_country_iso_codebodystringoptionalTwo-letter country code the web search runs from, e.g. 'US'. Sonar models always search the web.
05// responses

The Perplexity model's answer in `result[0].items[]` (`type: "message"`), with citations in its `sections[].annotations[]`.

200json
{
  "type": "object"
}
06// pricing
from $0.002per successful request

Metered endpoint — the exact cost depends on the request. Credits are deducted per successful call; failed requests (4xx/5xx) are not charged.

Get started at app.superagnt.com.

08// more from SEO

start calling

Point your client at https://mcp.superagnt.com/mcp and your agent has this endpoint, plus every other source on one balance.

Start free→