Sends a chat message history to the Perplexity Chat API, supporting all documented API parameters.
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,
.search_language_filter = NULL,
.language_preference = NULL,
.return_images = FALSE,
.image_domain_filter = NULL,
.image_format_filter = NULL,
.search_recency_filter = NULL,
.search_mode = "web",
.search_after_date_filter = NULL,
.search_before_date_filter = NULL,
.last_updated_after_filter = NULL,
.last_updated_before_filter = NULL,
.disable_search = FALSE,
.enable_search_classifier = FALSE,
.reasoning_effort = NULL,
.return_related_questions = FALSE,
.user_location = NULL,
.search_context_size = NULL,
.search_type = NULL,
.stream_mode = NULL,
.json_schema = 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
)An updated LLMMessage object with the assistant's reply and metadata, including citations and search_results.
An LLMMessage object containing the conversation history.
Model name to use (default: "sonar").
Max completion tokens (default: 1024).
Controls response randomness (0 < x < 2).
Nucleus sampling threshold (0 < x < 1).
Number > 0. Penalizes frequent tokens.
Numeric between -2 and 2. Penalizes present tokens.
Stop sequence(s), string or character vector/list.
Character vector of domains to allowlist/denylist (max 10; prefix with "-" to denylist).
ISO 639-1 language code to restrict search results (e.g. "en", "de", "fr").
ISO 639-1 code for preferred response language (e.g. "en").
Logical; if TRUE, returns images from search.
Character vector of domains to restrict image results to.
Character vector of image formats to include (e.g. c("png", "jpg")).
Restrict search to recent results: "hour", "day", "week", "month", or "year".
Search index to use: "web" (default), "academic", or "sec".
Only include content published after this date (MM/DD/YYYY).
Only include content published before this date (MM/DD/YYYY).
Only include content last updated after this date (MM/DD/YYYY).
Only include content last updated before this date (MM/DD/YYYY).
Logical; if TRUE, disables web search entirely (default: FALSE).
Logical; if TRUE, lets the model decide whether to search (default: FALSE).
Reasoning level: "low", "medium", or "high".
Logical; if TRUE, returns related questions.
Named list for geographic search personalisation. Accepted fields:
country (ISO 3166-1 alpha-2), city, region, latitude, longitude.
Example: list(country = "DE", city = "Berlin").
Amount of search context to include: "low", "medium" (default), or "high".
Search quality preference inside web_search_options: "fast", "pro", or "auto".
Response format: "full" (default) or "concise".
A tidyllm schema created with tidyllm_schema() for structured JSON output (optional).
Top-k token sampling (integer, 0 disables).
Named list with raw web_search_options overrides. Values set here take precedence over the dedicated parameters above.
API endpoint (default: "https://api.perplexity.ai/").
Timeout in seconds (default: 60).
If TRUE, streams response.
If TRUE, prints additional info.
Max request retries (default: 3).
If TRUE, returns constructed request instead of sending.