Skip to content

rgomezp/perplexity-sdk

Repository files navigation

Welcome to Perplexity.ai SDK 👋

Version Documentation Maintenance

The Perplexity.ai SDK is a powerful tool for integrating advanced AI capabilities into your applications. With a simple and intuitive API, you can leverage the power of Perplexity's AI models for chat completions, instructions, and more.

Overview

This Unofficial SDK is designed to provide developers with easy access to Perplexity's powerful AI models. It simplifies the process of sending requests and handling responses from various models including pplx-7b-chat, pplx-70b-chat, pplx-7b-online, pplx-70b-online, and others. The SDK is highly versatile, catering to a wide range of AI-driven applications.

Typescript supported.

Supported Models:

Model Context Length Model Type
codellama-34b-instruct 16384 Chat Completion
codellama-70b-instruct 16384 Chat Completion
llama-2-70b-chat 4096 Chat Completion
mistral-7b-instruct 4096 Chat Completion
mixtral-8x7b-instruct 4096 Chat Completion
pplx-7b-chat 8192 Chat Completion
pplx-70b-chat 4096 Chat Completion
pplx-7b-online 4096 Chat Completion
pplx-70b-online 4096 Chat Completion

Install

You can easily install the Perplexity.ai SDK via npm or yarn.

# npm
npm install perplexity-sdk

# yarn
yarn add perplexity-sdk

Configuration

To use the SDK, you need to configure it with your API key. Here's a simple setup:

import Perplexity from 'perplexity-sdk';

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

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

Usage

Here's how you can use the SDK to send a request to Perplexity's AI models:

import { ChatCompletionsPostRequestModelEnum } from 'perplexity-sdk';

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

console.log(result);

Versioning

Make sure to keep your SDK version updated to leverage new features and improvements. The current version can be found on the npm page.

API

Visit Perplexity Labs' Official API Reference.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Donate

Bitcoin: bc1qhp9havdzfzqr9mzdc3257txmegrpryhx3kdpyz

Strike: rodrigo

📝 License

This project is MIT licensed.

About

The Unofficial Node.js SDK for Perplexity.ai

Resources

License

Stars

Watchers

Forks

Packages

No packages published