Crates.io | openai-rust |
lib.rs | openai-rust |
version | 1.5.2 |
source | src |
created_at | 2023-03-18 17:36:23.277677 |
updated_at | 2023-12-19 14:18:45.703024 |
description | An unofficial library for the OpenAI API |
homepage | |
repository | https://github.com/LevitatingBusinessMan/openai-rust |
max_upload_size | |
id | 813874 |
size | 81,125 |
This is an unofficial library to interact with the Openai-API. The goal of this crate is to support the entire api while matching the offical documentation as closely as possible.
// Here we will use the chat completion endpoint
let client = openai_rust::Client::new(&std::env::var("OPENAI_API_KEY").unwrap());
let args = openai_rust::chat::ChatArguments::new("gpt-3.5-turbo", vec![
openai_rust::chat::Message {
role: "user".to_owned(),
content: "Hello GPT!".to_owned(),
}
]);
let res = client.create_chat(args).await.unwrap();
println!("{}", res);
You can run this code as an example with OPENAI_API_KEY=(your key) cargo run --example chat
.
Checkout the examples directory for more usage examples. You can find documentation on docs.rs.