Introducing the Unofficial Perplexity SDK for Node.js

rgomezp

Rodrigo Gomez Palacio

Posted on February 7, 2024

Introducing the Unofficial Perplexity SDK for Node.js

Overview

In today's ever-evolving tech landscape, innovative tools and frameworks are pivotal in shaping how we interact with technology. One such groundbreaking addition is the Perplexity.

The Unofficial Perplexity SDK for Node.js is a tool designed to bring you access to Perplexity.ai on Node.js.

How it was made

I built this project using OpenAPI. OpenAPI, an open-source format, played a crucial role in easily generating the SDK and will allow for simple updates.

Install

# npm
npm install perplexity-sdk

# yarn
yarn add perplexity-sdk
Enter fullscreen mode Exit fullscreen mode

Usage

import Perplexity from 'perplexity-sdk';
import { ChatCompletionsPostRequestModelEnum } from 'perplexity-sdk';

const config = {
  apiKey: process.env.PERPLEXITY_API_KEY || '<YOUR_API_KEY>'
};

const perplexity = new Perplexity(config).client();

const result = await perplexity.chatCompletionsPost({
  model: ChatCompletionsPostRequestModelEnum.Mistral7bInstruct,
  messages: [{
    "role": "user",
    "content": "Your prompt here"
  }],
});

console.log(result);

Enter fullscreen mode Exit fullscreen mode

Show your support

Please give a ⭐️ if this project helped you! That's all I ask.

💖 💪 🙅 🚩
rgomezp
Rodrigo Gomez Palacio

Posted on February 7, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related