A Rust client for OpenAI's API

Overview

GitHub Workflow Status GitHub Crates.io docs.rs

libopenai - Rust client to interact with OpenAI's API

Rust client for OpenAI's API, written with tokio and reqwest

How to use

To add libopenai to your project, you just need to run the following command on your project's main foler:

cargo add libopenai

Example

use libopenai::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    // OPTIONAL: Load variables in a `.env` file into the enviroment
    dotenv::dotenv().unwrap();

    let client = Client::new(
        None, // Gets api key from `OPENAI_API_KEY` enviroment variable
        None, // No organization specified
    )?;

    // Send basic completion request
    let basic = Completion::new(
        "text-davinci-003",
        "Whats the best way to calculate a factorial?",
        &client,
    )
    .await?;

    // Print the result
    println!("{:#?}", basic);
    return Ok(());
}

Features

Cargo features

Currently, the only feature available is tracing, which enables some minor logging

You might also like...
Neovide - No Nonsense Neovim Client in Rust
Neovide - No Nonsense Neovim Client in Rust

Neovide This is a simple graphical user interface for Neovim (an aggressively refactored and updated Vim editor). Where possible there are some graphi

Nostr CLI client built with Rust

Nostr CLI client built with Rust Encrypted chat inside Nostr leaks metadata of who talks to who. This small CLI app implements a "public inbox," which

Simple but convenient CLI-based Matrix client app for sending and receiving (in Rust)

matrix-commander-rs simple but convenient CLI-based Matrix client app for sending and receiving Help create this Rust program! This project is current

Open source email client written in Rust and Dioxus. Under πŸ—οΈ
Open source email client written in Rust and Dioxus. Under πŸ—οΈ

Blazemail A full-featued, beautiful, mail client that doesn't suck. Works on mac, windows, linux, mobile, web, etc. Features, status Blazemail is curr

easy-to-use immediate mode client side Rust web framework
easy-to-use immediate mode client side Rust web framework

An immediate mode web frontend library written in Rust. It builds up VDOM for not having to run too many DOM operations, but as it runs every time any

⚑ Blazing fast async/await HTTP client for Python written on Rust using reqwests

Reqsnaked Reqsnaked is a blazing fast async/await HTTP client for Python written on Rust using reqwests. Works 15% faster than aiohttp on average RAII

BingGPT command line client, written in rust.
BingGPT command line client, written in rust.

BingGPT BingGPT command line client, written in rust δΈ­ζ–‡θ―΄ζ˜Ž This project is a rust language implementation of EdgeGPT, all the hard stuff was done by th

Rust client-side implementation of the rock usb protocol

Utility crates to interact with Rockchip devices Rockchip SoCs implement a custom USB protocol when starting in a special recovery mode (sometimes cal

ChatGPT-rs is a lightweight ChatGPT client with a graphical user interface, written in Rust
ChatGPT-rs is a lightweight ChatGPT client with a graphical user interface, written in Rust

ChatGPT-rs is a lightweight ChatGPT client with a graphical user interface, written in Rust. It allows you to chat with OpenAI's GPT models through a simple and intuitive interface.

Releases(v0.1.0)
Owner
Alex
Alex
Api testing tool made with rust to use for api developement (Kind of Tui)

Api testing tool made with rust to use for api developement (Kind of Tui) This Rust project provides a simple yet powerful tool for making HTTP reques

Kythonlk 3 Feb 14, 2024
Provides a mock Ambi client that emulates real sensor hardware such as an Edge client

ambi_mock_client Provides a mock Ambi client that emulates real sensor hardware such as an Edge client. Usage You must have Rust installed to build am

Rust Never Sleeps 2 Apr 1, 2022
API Client to Generate AI ASCII Art 🦾🧠

Charisma Charisma serves a purpose of being a bridge between Dall-e mini. It's used to generate ASCII Art directly from your terminal. It uses Craiyon

camel_case 3 Jul 23, 2023
A simple API client (postman like) in your terminal

ATAC βš”?? Table Of Contents Description How to use Binary Compile by yourself Features Current TODO v1.0.0 TODO v2.0.0 Documentation Technical precisio

Julien C. 5 Feb 29, 2024
List public items (public API) of library crates. Enables diffing public API between releases.

cargo-public-items List public items (the public API) of a Rust library crate by analyzing the rustdoc JSON of the crate. Automatically builds the rus

Martin Nordholts 203 Dec 31, 2022
Rust API Server: A versatile template for building RESTful interfaces, designed for simplicity in setup and configuration using the Rust programming language.

RUST API SERVER Introduction Welcome to the Rust API Server! This server provides a simple REST interface for your applications. This README will guid

Harry Nguyen 3 Feb 25, 2024
Rust TUI client for steamcmd

Steam TUI About Just a simple TUI client for steamcmd. Allows for the graphical launching, updating, and downloading of steam games through a simple t

Dylan Madisetti 599 Jan 9, 2023
A user-friendly TUI client for Matrix written in Rust!

Konoha A user-friendly TUI client for Matrix written in Rust! Notice: The client is currently not usable and is only hosted on GitHub for version cont

L3af 9 Jan 5, 2022
A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Vagelis Prokopiou 4 Aug 14, 2022
nhdl - a command-line doujinshi downloader client built in rust!

nhdl nhdl - a command-line doujinshi downloader client built in rust! goals fast and asynchronous doujinshi downloader, supporting various doujinshi s

Lumine 2 Dec 23, 2022