open_ai_rust 0.2.15

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
use crate::{API_KEY, OPENAI_MSG_ENDPOINT};



pub fn get_url(end_point: &str) -> Result<String, String> {
    let mut url = {
        let url = OPENAI_MSG_ENDPOINT.lock().map_err(|e| format!("Error getting Embeddings endpoint from Mutex lock: {}", e))?;
        if url.is_empty() {
            "https://api.openai.com".to_string()
        } else {
            return Ok(url.to_string())
        }
    };

    url.push_str(end_point);
    println!("Using URL: {}", url);
    Ok(url)
}

pub fn get_key() -> Result<String, String> {
    match API_KEY.lock() {
        Ok(key) => Ok(key.clone()),
        Err(e) => return Err(format!("Error getting API key from Mutex lock: {}", e))
    }
}