16 releases (2 stable)

1.5.2 Dec 19, 2023
1.5.1 Dec 6, 2023
0.5.1 Jul 9, 2023
0.5.0 Jun 23, 2023
0.1.5 Mar 26, 2023

#1237 in Web programming

Download history 38/week @ 2024-09-02 53/week @ 2024-09-09 3/week @ 2024-09-16 24/week @ 2024-09-23 66/week @ 2024-09-30 37/week @ 2024-10-07 42/week @ 2024-10-14 109/week @ 2024-10-21 24/week @ 2024-10-28 14/week @ 2024-11-04 13/week @ 2024-11-11 16/week @ 2024-11-18 45/week @ 2024-11-25 22/week @ 2024-12-02 35/week @ 2024-12-09 9/week @ 2024-12-16

113 downloads per month
Used in 3 crates

MIT license

46KB
575 lines

openai-rust

Test Status Crates.io docs.rs

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.

Current features:

Example usage

// 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.

Projects using openai-rust

Dependencies

~4–16MB
~223K SLoC