Expand description
§openai-rust
This is an unofficial library to interact with the Openai-API. The goal of this crate is to support the entire api while matching the offical documentation as closely as possible.
§Current features:
- Listing models
- Completions
- Chat
- Streaming Chat
- Edit
- Embeddings
- Images
- Audio
- Files
- Moderations
- Fine-tuning
§Example usage
ⓘ
// Here we will use the chat completion endpoint
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).await.unwrap();
println!("{}", res);
You can run this code as an example with OPENAI_API_KEY=(your key) cargo run --example chat
.
Checkout the examples directory for more usage examples. You can find documentation on docs.rs.
§Projects using openai-rust
- openai-cli: a CLI for interacting with GPT.
- gpt-cli-rust: Another CLI.
- electocracy: A digital voting system.
- awsgpt: Interact with the aws-cli via GPT.
Re-exports§
pub extern crate futures_util;
Modules§
- chat
- See https://platform.openai.com/docs/api-reference/chat. Use with Client::create_chat or Client::create_chat_stream.
- completions
- See https://platform.openai.com/docs/api-reference/completions. Use with Client::create_completion.
- edits
Deprecated - See https://platform.openai.com/docs/api-reference/edits. Use with Client::create_edit.
- embeddings
- See https://platform.openai.com/docs/api-reference/embeddings. Use with Client::create_embeddings.
- images
- See https://platform.openai.com/docs/api-reference/images. Use with Client::create_image.
- models
- See https://platform.openai.com/docs/api-reference/models. Use with Client::list_models.
Structs§
- Client
- This is the main interface to interact with the api.