| Crates.io | perplexity |
| lib.rs | perplexity |
| version | 0.1.1 |
| created_at | 2024-09-16 08:02:32.634642+00 |
| updated_at | 2024-09-18 05:26:57.634383+00 |
| description | Perplexity Rust SDK |
| homepage | https://github.com/roushou/mesh |
| repository | https://github.com/roushou/mesh |
| max_upload_size | |
| id | 1376111 |
| size | 19,847 |
This is an unofficial Rust SDK for the Perplexity API.
More information about this crate can be found in the crate documentation.
Add perplexity as a dependency to your Cargo.toml
$ cargo add perplexity
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);
}
This project is licensed under the MIT license and Apache-2.0 license.