open_ai_rust 0.2.16

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 std::sync::Mutex;


pub mod logoi;
pub mod requests;
pub mod helpers;

static API_KEY: Mutex<String> = Mutex::new(String::new());
static OPENAI_MSG_ENDPOINT: Mutex<String> = Mutex::new(String::new());
static EMBEDDINGS_ENDPOINT: Mutex<String> = Mutex::new(String::new());

pub fn set_key(value: String) {
    *API_KEY.lock().unwrap() = value;
}

pub fn set_ai_msg_endpoint(value: String) {
    *OPENAI_MSG_ENDPOINT.lock().unwrap() = value;
}

pub fn set_ai_msg_endpoint_default() {
    *OPENAI_MSG_ENDPOINT.lock().unwrap() = "https://api.openai.com/v1/chat/completions".to_string();
}

pub fn set_embeddings_endpoint(value: String) {
    *EMBEDDINGS_ENDPOINT.lock().unwrap() = value;
}

pub fn set_embeddings_endpoint_default() {
    *EMBEDDINGS_ENDPOINT.lock().unwrap() = "https://api.openai.com/v1/embeddings".to_string();
}

#[derive(Clone, Copy)]
pub enum RequestType {
    ChatCompletion,
    Embedding,
}