View source: R/api_perplexity.R
perplexity_chat | R Documentation |
Sends a chat message history to the Perplexity Chat API, supporting all documented API parameters as of July 2025.
perplexity_chat(
.llm,
.model = "sonar",
.max_tokens = 1024,
.temperature = NULL,
.top_p = NULL,
.frequency_penalty = NULL,
.presence_penalty = NULL,
.stop = NULL,
.search_domain_filter = NULL,
.return_images = FALSE,
.search_recency_filter = NULL,
.search_mode = "web",
.reasoning_effort = NULL,
.return_related_questions = FALSE,
.search_after_date_filter = NULL,
.search_before_date_filter = NULL,
.last_updated_after_filter = NULL,
.last_updated_before_filter = NULL,
.top_k = NULL,
.web_search_options = NULL,
.api_url = "https://api.perplexity.ai/",
.timeout = 60,
.stream = FALSE,
.verbose = FALSE,
.max_tries = 3,
.dry_run = FALSE
)
.llm |
An |
.model |
Model name to use (default: "sonar"). |
.max_tokens |
Max completion tokens (default: 1024). |
.temperature |
Controls response randomness (0 < x < 2). |
.top_p |
Nucleus sampling threshold (0 < x < 1). |
.frequency_penalty |
Number > 0. Penalizes frequent tokens. |
.presence_penalty |
Numeric between -2 and 2. Penalizes present tokens. |
.stop |
Stop sequence(s), string or character vector/list. |
.search_domain_filter |
Domains to allowlist/denylist for search (max 10, "-domain" for denylist). |
.return_images |
Logical; if TRUE, returns images from search. |
.search_recency_filter |
Restrict search to recent ("hour","day","week","month"). |
.search_mode |
"web" (default) or "academic" (prioritize scholarly sources). |
.reasoning_effort |
Reasoning level: "low", "medium" (default), "high" (for deep research models). |
.return_related_questions |
Logical; if TRUE, returns related questions. |
.search_after_date_filter |
Only content published after date (mm/dd/yyyy). |
.search_before_date_filter |
Only content published before date (mm/dd/yyyy). |
.last_updated_after_filter |
Only content updated after date (mm/dd/yyyy). |
.last_updated_before_filter |
Only content updated before date (mm/dd/yyyy). |
.top_k |
Top-k token sampling (integer, 0 disables). |
.web_search_options |
Named list with search config (e.g. list(search_context_size = "high")). |
.api_url |
API endpoint (default: "https://api.perplexity.ai/"). |
.timeout |
Timeout in seconds (default: 60). |
.stream |
If TRUE, streams response. |
.verbose |
If TRUE, prints additional info. |
.max_tries |
Max request retries (default: 3). |
.dry_run |
If TRUE, returns constructed request instead of sending. |
An updated LLMMessage
object with the assistant's reply and metadata, including citations and search_results.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.