Crates.io | openai-rs-api |
lib.rs | openai-rs-api |
version | 1.1.3 |
source | src |
created_at | 2023-07-03 15:38:18.654606 |
updated_at | 2023-07-07 17:42:18.483927 |
description | A Rust wrapper for the OpenAI API |
homepage | |
repository | |
max_upload_size | |
id | 907133 |
size | 96,070 |
Unofficial api client for OpenAI
core
moduleuse openai_rs_api::core::models::chat::{ChatParameters, ChatResponse, Message};
use openai_rs_api::core::OpenAI;
#[tokio::main]
async fn main() {
let oai = OpenAI::new("API_KEY".to_string(), "API_ORG".to_string());
let parameters = ChatParameters::new(
"gpt-3.5-turbo-16k".to_string(),
vec![Message {
role: "user".to_string(),
content: Some("Hello, my name is".to_string()),
name: None,
function_call: None,
}],
);
let response: ChatResponse = oai.create_chat_completions(parameters).await.unwrap();
// print answer message
if let Some(content) = &response.choices.get(0).unwrap().message.content {
println!("{}", content);
}
}