rust-openai-lib

Crates.iorust-openai-lib
lib.rsrust-openai-lib
version0.1.0
sourcesrc
created_at2024-01-23 13:14:01.818582
updated_at2024-01-23 13:14:01.818582
descriptionA Rust library for OpenAI API integration
homepagehttps://github.com/lavryniukk/rust-openai-lib
repositoryhttps://github.com/lavryniukk/rust-openai-lib
max_upload_size
id1110811
size9,724
Lev Lavryniuk (0x4C656F)

documentation

README

rust-openai-lib

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.

Installation

Install this project with cargo

cargo install rust-openai-lib

Usage/Examples

use rust-openai-lib::{Model, Openai};

let openai = Openai::new("your-api-key", Model::Gpt35Turbo);

API Reference

Initialize OpenAI

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

Get chat completion

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.

Commit count: 0

cargo fmt