OpenAI Rust SDK

This is an unofficial Rust SDK for the OpenAI API.
More information about this crate can be found in the crate documentation.
Installation
Add opai as a dependency to your Cargo.toml
$ cargo add opai
Usage
An example to create a completion.
use opai::{
chat::message::{CreateChatCompletion, Message, Role},
client::Client,
config::Config,
models::gpt::GptModel,
};
#[tokio::main]
async fn main() {
let config = Config::from_env().unwrap();
let client = Client::new(config).unwrap();
let messages: Vec<Message> = vec![Message {
content: "Hello World".into(),
role: Role::User,
name: None,
}];
let request = CreateChatCompletion::new(GptModel::GPT4o, messages);
let completion = client.chat.create_completion(request).await.unwrap();
println!("{:?}", completion);
}
License
This project is licensed under the MIT license and Apache-2.0 license.