Endpoint
Replace
localhost:3000 with your Perplexica instance URL if running on a different host or port.Request body
object
required
The message object containing the user’s input and metadata.
object
required
Defines the chat model to be used. Get available providers and models from the
/api/providers endpoint.object
required
Defines the embedding model for similarity-based searching.
string
required
Optimization mode to control performance and quality balance. Available values:
speed, balanced, quality.array
default:[]
Which search sources to enable. Available values:
web, academic, discussions.array
default:[]
An array of message pairs representing the conversation history. Each pair consists of a role (either
human or assistant) and the message content.array
default:[]
An array of file IDs to include in the context for this message.
string
default:""
Custom instructions to guide the AI’s response. Set to
null or empty string for default behavior.Response
The chat endpoint returns a streaming response withContent-Type: text/event-stream. Each line contains a newline-delimited JSON object representing different types of events.
Stream event types
object
A new content block has been created. Contains the block object with its initial state.
object
An existing block has been updated.
object
Indicates that the research phase is complete and the AI is ready to generate the final response.
object
Indicates the message stream has completed successfully.
object
An error occurred during processing.
Request example
Response example
Error responses
Bad Request
Returned if the request body is invalid or missing required fields. The response will include detailed error information with field paths and validation messages.
Internal Server Error
Returned if an error occurs while processing the chat request.