open_ai_rust 0.2.13

Open AI SDK for Rust. To my knowledge, the only fully comprehensive and up-to-date Open AI crate built in and for Rust. Provides both low-level control with high level ergonomics for doing cool things (the whole reason we use Rust in the first place). Is maintained and has been used and tested in products used in production.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#[cfg(test)]
mod tests {
    use open_ai_rust::{requests::embed::embed, set_key};


    #[tokio::test]
    async fn can_embed_text() {
        dotenv::dotenv().ok();
        set_key(std::env::var("OPENAI_SK").unwrap()); // Set the OpenAI API key from the environment variable
        let text = "Hello, world!".to_string();
        let embedding = embed(text, None).await.unwrap();
        assert_eq!(embedding.len(), 1536);
    }
}