DEV Community

Cover image for Introducing the Unofficial Perplexity SDK for Node.js
Rodrigo Gomez Palacio
Rodrigo Gomez Palacio

Posted on

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.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (1)

Collapse
 
rgomezp profile image
Rodrigo Gomez Palacio

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay