Endpoint
Replace
localhost:3000 with your Perplexica instance URL if running on a different host or port.Request body
Defines the chat model to be used for the query. Get available providers and models from the
/api/providers endpoint.Defines the embedding model for similarity-based searching. Get available providers and models from the
/api/providers endpoint.Which search sources to enable. Available values:
web, academic, discussions.The search query or question.
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)
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: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.
When set to
true, enables streaming responses using Server-Sent Events (SSE).Response
Standard response (stream: false)
The search result, generated based on the query and enabled sources.
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
Returned if the request is malformed or missing required fields (e.g., no
sources or query).Returned if an internal server error occurs during the search.