Learn R Programming

gptstudio (version 0.4.0)

query_api_perplexity: Send a request to the Perplexity API and return the response

Description

This function sends a JSON post request to the Perplexity API, retries on failure up to three times, and returns the response. The function handles errors by providing a descriptive message and failing gracefully.

Usage

query_api_perplexity(request_body, api_key = Sys.getenv("PERPLEXITY_API_KEY"))

Value

A parsed JSON object as the API response.

Arguments

request_body

A list containing the body of the POST request.

api_key

String containing a Perplexity API key. Defaults to the PERPLEXITY_API_KEY environmental variable if not specified.