Endpoint
Replace
localhost:3000 with your Perplexica instance URL if running on a different host or port.Request body
object
required
Defines the chat model to be used for the query. Get available providers and models from the
/api/providers endpoint.object
required
Defines the embedding model for similarity-based searching. Get available providers and models from the
/api/providers endpoint.array
required
Which search sources to enable. Available values:
web, academic, discussions.string
required
The search query or question.
string
default:"speed"
Specifies the optimization mode to control the balance between performance and quality.Available modes:
speed: Prioritize speed and return the fastest answerbalanced: Provide a balanced answer with good speed and reasonable qualityquality: Prioritize answer quality (may be slower)
array
An array of message pairs representing the conversation history. Each pair consists of a role (either
human or assistant) and the message content. This allows the system to use the context of the conversation to refine results.Example:string
Custom instructions provided by the user to guide the AI’s response. These instructions are treated as user preferences and have lower priority than the system’s core instructions. For example, you can specify a particular writing style, format, or focus area.
boolean
default:false
When set to
true, enables streaming responses using Server-Sent Events (SSE).Response
Standard response (stream: false)
string
The search result, generated based on the query and enabled sources.
array
A list of sources that were used to generate the search result.
Streaming response (stream: true)
When streaming is enabled, the API returns a stream of newline-delimited JSON objects using Server-Sent Events (SSE). Each line contains a complete, valid JSON object. The response hasContent-Type: text/event-stream.
The different message types include:
init: Initial connection messagesources: All sources used for the responseresponse: Chunks of the generated answer textdone: Indicates the stream is complete
Request example
Response example
Error responses
Bad Request
Returned if the request is malformed or missing required fields (e.g., no
sources or query).Internal Server Error
Returned if an internal server error occurs during the search.