Logo

Perplexity

Authentication Type: API Key
Description: AI-powered answer engine that provides accurate, trusted, and real-time answers with web search capabilities.


Chat Completions

Generate AI responses with real-time web search capabilities.

Chat Completions

Generate conversational AI responses with real-time web search, citations, and various search filters. Supports Sonar models: sonar (lightweight), sonar-reasoning (fast reasoning), and sonar-deep-research (comprehensive research).

Operation Type: Query (Read)

Parameters:

  • model string (required): The Perplexity model to use for chat completion. Options: "sonar", "sonar-reasoning", "sonar-deep-research". Defaults to "sonar"
  • messages array of objects (required): Array of chat messages
    • role string (required): Message role. Options: "system", "user", "assistant"
    • content string (required): Message content
  • maxTokens number (nullable): Maximum number of tokens to generate
  • temperature number (nullable): Sampling temperature (0-2)
  • topP number (nullable): Top-p sampling parameter
  • searchDomainFilter array of strings (nullable): Array of domains to search within (e.g., ["example.com"])
  • searchRecencyFilter string (nullable): Time range for search results. Options: "hour", "day", "week", "month", "year"
  • returnCitations boolean (nullable): Whether to return citations in the response
  • returnImages boolean (nullable): Whether to return images in the response
  • returnRelatedQuestions boolean (nullable): Whether to return related questions
  • searchType string (nullable): Type of search to perform. Options: "general", "news", "academic"

Returns:

  • id string: Unique identifier for the completion
  • object string: Object type (chat.completion)
  • created number: Unix timestamp of creation
  • model string: Model used for completion
  • choices array of objects: Array of completion choices
    • index number: Choice index
    • message object: Generated message
      • role string: Message role
      • content string: Generated message content
    • finishReason string (nullable): Reason the generation finished
    • delta object (nullable): Delta information
  • usage object: Token usage information
    • promptTokens number: Number of tokens in the prompt
    • completionTokens number: Number of tokens in the completion
    • totalTokens number: Total number of tokens used
  • citations array of strings (nullable): Source citations for the response
  • images array of strings (nullable): Related images for the response
  • relatedQuestions array of strings (nullable): Related questions

Example Usage:

{
  "model": "sonar-reasoning",
  "messages": [
    {
      "role": "system",
      "content": "You are a research assistant that provides accurate, well-sourced information."
    },
    {
      "role": "user",
      "content": "What are the latest developments in renewable energy storage technology?"
    }
  ],
  "maxTokens": 1000,
  "temperature": 0.2,
  "topP": 0.9,
  "searchDomainFilter": ["ieee.org", "nature.com", "science.org"],
  "searchRecencyFilter": "month",
  "returnCitations": true,
  "returnImages": true,
  "returnRelatedQuestions": true,
  "searchType": "academic"
}

Common Use Cases

Real-time Research and Analysis:

  • Generate up-to-date research reports with current information and academic sources
  • Filter search results to recent timeframes for breaking news analysis and trend identification
  • Access domain-specific information from trusted sources like scientific journals and government sites

Content Creation with Citations:

  • Create well-sourced articles and blog posts with automatic citation generation
  • Generate educational content with academic references and supporting images
  • Produce market research reports with current data and visual supporting materials

Question-Answering Systems:

  • Build intelligent FAQ systems that provide current, accurate answers with source verification
  • Create research assistants that suggest related questions for deeper exploration
  • Develop customer support systems with access to real-time product information and updates

Academic and Professional Research:

  • Conduct literature reviews with filtering for academic sources and recent publications
  • Generate research summaries with comprehensive citations and related visual content
  • Create briefing documents with current information filtered by domain authority and publication recency