Crates.io | rust-openai-lib |
lib.rs | rust-openai-lib |
version | 0.1.0 |
source | src |
created_at | 2024-01-23 13:14:01.818582 |
updated_at | 2024-01-23 13:14:01.818582 |
description | A Rust library for OpenAI API integration |
homepage | https://github.com/lavryniukk/rust-openai-lib |
repository | https://github.com/lavryniukk/rust-openai-lib |
max_upload_size | |
id | 1110811 |
size | 9,724 |
This project is a Rust library for interacting with the OpenAI API. It provides a simple and intuitive interface for sending requests to the API and processing the responses. The library supports various features of the OpenAI API, including chat completions. It's designed for developers who want to integrate OpenAI's powerful AI models into their Rust applications.
Install this project with cargo
cargo install rust-openai-lib
use rust-openai-lib::{Model, Openai};
let openai = Openai::new("your-api-key", Model::Gpt35Turbo);
let openai = Openai::new("your-api-key", Model::Gpt35Turbo);
Parameter | Type | Description |
---|---|---|
api_key | String |
Your OpenAI API key |
model | Model |
The model to use |
Returns: Openai
let messages = vec![Message {
"role": "user",
"content": "Hello world"
}];
let response = openai.get_chat_completion(messages).await.unwrap();
Parameter | Type | Description |
---|---|---|
messages | Vec<Message> |
List of messages for the chat completion |
Returns: Result<Value, Error>
Where Value
is response object.