openai-rust2 1.7.6

An unofficial library for the OpenAI API (OpenAI-compatible endpoints, streaming chat, Responses API, images)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Here we will use the chat completion endpoint
use openai_rust2 as openai_rust;

#[tokio::main]
async fn main() {
    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, None).await.unwrap();
    println!("{}", res);
}