2 releases

0.1.1 Sep 18, 2024
0.1.0 Sep 16, 2024

#2088 in Web programming

Download history 304/week @ 2024-09-14 41/week @ 2024-09-21 15/week @ 2024-09-28 1/week @ 2024-10-05 1/week @ 2024-10-12

58 downloads per month

MIT AND Apache-2.0

20KB
362 lines

Perplexity Rust SDK

Crates.io MIT licensed APACHE-2.0 licensed Build Status

This is an unofficial Rust SDK for the Perplexity API.

More information about this crate can be found in the crate documentation.

Installation

Add perplexity as a dependency to your Cargo.toml

$ cargo add perplexity

Usage

An example to create a completion.

use perplexity::{
    client::{Client, CreateChatCompletion, Model},
    config::Config,
};

#[tokio::main]
async fn main() {
    let api_key = std::env::var("PERPLEXITY_API_KEY")
        .expect("environment variable PERPLEXITY_API_KEY should be defined");

    let config = Config::new(api_key);
    let client = Client::new(config).unwrap();

    let message = CreateChatCompletion::new(Model::Llama31SonarLargeOnline);
    let result = client.create_completion(message).await.unwrap();
    println!("{:?}", result);
}

License

This project is licensed under the MIT license and Apache-2.0 license.

Dependencies

~7–18MB
~234K SLoC