Skip to contents

This function sends a series of messages alongside a chosen model to the Perplexity API to generate a chat completion. It returns the API's generated responses.

Usage

create_completion_perplexity(
  prompt,
  model = "mistral-7b-instruct",
  api_key = Sys.getenv("PERPLEXITY_API_KEY")
)

Arguments

prompt

A list containing prompts to be sent in the chat.

model

A character string representing the Perplexity model to be used. Defaults to "mistral-7b-instruct".

api_key

The API key for accessing the Perplexity API. Defaults to the PERPLEXITY_API_KEY environment variable.

Value

The response from the Perplexity API containing the completion for the chat.