Overview
The Perplexity endpoint allows you to extract structured data from Perplexity AI about your brand, products, or any topic across various regions. This endpoint processes your prompts through Perplexity and returns parsed responses with real-time sources & citations.Request Parameters
Required Parameters
prompt(string): The prompt to send to Perplexity (1-10,000 characters)
Optional Parameters
country(string): Optional country/region code for localized data extraction. Defaults to"US"include(object): Optional flags for including additional response formatsmarkdown(boolean): Include markdown-formatted response in the result. Defaults tofalse
Response Format Options
By default, all responses include both text and HTML formats. You can optionally include markdown:| Parameter | Default | Description | Use cases | Cost |
|---|---|---|---|---|
include.markdown | false | Include markdown-formatted response in the result | Documentation, content integration | 3 credits |
Example Usage
Basic Request
Request with Markdown Format
Response Schema
All successful responses include these fields:| Field | Type | Description |
|---|---|---|
success | boolean | Always true for successful responses |
result.text | string | Perplexity’s response text |
result.sources | array | Array of sources referenced in the response |
result.html | string | Perplexity’s response formatted in HTML (always included) |
result.markdown | string | Perplexity’s response formatted in Markdown (included when include.markdown is true) |
Error Responses
The API returns standard HTTP status codes to indicate the success or failure of requests. All error responses follow a consistent format with an error object containing a code, message, details, and timestamp.Status Codes
200- Success400- Bad Request (validation error)401- Unauthorized (authentication error)403- Forbidden (insufficient permissions or credits)404- Not Found (route not found)409- Conflict (resource conflict)429- Too Many Requests499- Client Closed Request (request was canceled)500- Internal Server Error502- Bad Gateway (external service error)
Validation Errors
| Field | Error | Description |
|---|---|---|
prompt | ”Prompt cannot be empty” | Must be 1-10,000 characters |
prompt | ”Prompt is too long” | Exceeds 10,000 character limit |
country | ”Invalid country code” | Must be valid ISO 3166-1 alpha-2 code |
include.markdown | ”Expected boolean” | Must be true or false |
Concurrency Information
Concurrency information is included in response headers:X-Concurrent-Limit: Maximum number of concurrent requests allowedX-Concurrent-Current: Current number of concurrent requestsX-Concurrent-Remaining: Number of remaining concurrent slots available
Credits System
This endpoint uses a credit-based billing system:- Base cost: 3 credits per request
- Additional costs: +0 credits (markdown format is included at no extra charge)
X-Credits-Remaining: Number of credits remaining in your accountX-Credits-Charged: Number of credits charged for this request
Supported Country Codes
The API accepts ISO 3166-1 alpha-2 country codes for thecountry parameter to extract data from different regions. For a complete list of supported country codes, see the Countries endpoint.
Common Examples:
US- United StatesGB- United KingdomCA- CanadaAU- AustraliaDE- GermanyFR- FranceJP- JapanCN- ChinaIN- IndiaBR- Brazil
Best Practices
Prompt Guidelines
- Real-time Information: Ask about current events, news, or trending topics for best results
- Research Questions: Frame prompts as research or information-gathering questions
- Source Quality: Perplexity excels at providing recent, well-sourced information
Implementation Guidelines
- Handle Real-time Sources: Process sources array to provide current web references
- Use Markdown: Enable markdown format when integrating with research tools or documentation
- Error Handling: Implement robust error handling for failed extraction requests
- Rate Limiting: Respect concurrency limits and implement proper retry logic
- Source Verification: Validate source URLs as they represent real-time web content
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Request parameters for monitoring Perplexity responses