> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Perplexity API — answers, citations and search queries

> Ask Perplexity a question and get its answer, cited sources, related questions, search queries and media.

`PERPLEXITY` asks Perplexity and returns the answer with the sources it cited and the searches its model ran.

| | |
| - | - |
| taskType | `PERPLEXITY` |
| Reads | `prompt` (falls back to `query`) |
| Credits | 1 |
| Country | Optional, default `US`. `CN` is rejected with `422 REGION_UNSUPPORTED`. |

## Request

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/async/task \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "taskType": "PERPLEXITY", "payload": { "prompt": "best CRM for a small team", "country": "US", "include": { "searchQueries": true } } }'
```

## Response

| Field | Type | Description |
| - | - | - |
| `text` | string | The answer. Always present. |
| `sources` | array | Cited sources: `position`, `url`, `label`, `description`. Always present. |
| `related_queries` | string\[] | Follow-up questions Perplexity suggests. |
| `search_model_queries` | array | The searches Perplexity's model ran, each `{ query, engine, limit }`. |
| `searchQueries` | string\[] | The same searches as plain strings. Only with `include.searchQueries`. |
| `images`, `videos` | array | Media shown with the answer: `title`, `url`, `medium`, `image`, `thumbnail`, `source`, `image_width`, `image_height`, and `duration` on a video. |
| `markdown` | string | The answer as Markdown, images in place. Only with `include.markdown`. |
| `rawResponse` | array | Parsed stream events. Only with `include.rawResponse`. |

In `images` and `videos`, `url` is the page the item comes from and `image` is the picture itself.

For example:

```json theme={"theme":"css-variables"}
{
  "text": "HubSpot CRM and Pipedrive are the most common choices for small teams ...",
  "sources": [
    { "position": 1, "url": "https://www.example.com/crm-review", "label": "Best CRM for small teams", "description": "..." }
  ],
  "related_queries": ["Is HubSpot CRM free?"],
  "search_model_queries": [{ "query": "best CRM small team", "engine": "web", "limit": 8 }],
  "searchQueries": ["best CRM small team"]
}
```

`related_queries` are suggestions for the user. `search_model_queries` and `searchQueries` are what Perplexity actually searched.

## Include flags

| Flag | Effect |
| - | - |
| `markdown` | Adds `markdown`. |
| `searchQueries` | Adds `searchQueries`. |
| `rawResponse` | Adds `rawResponse`. |
| `html` | Adds `html`, the screen Perplexity showed, for 0.25 credits when the page is stored. See [HTML pages](/engines/html-pages.md). |
| `analysis` | Adds `analysis`, 1 credit. See [Answer analysis](/engines/answer-analysis.md). |
| `citationAnalysis` | Runs a [Citation Analysis](/research/citation-analysis.md) on the answer. |

`ads` and `shopping` have no effect. See [Markdown and raw responses](/engines/response-options.md).

## Related

* [Perplexity product page](https://querying.ai/en/engines/perplexity)
* [Engine overview](/engines/overview.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.