#openai #api-client #ai-api

openai_client

Client library for using the OpenAi Api

1 unstable release

0.1.0 Dec 23, 2022

#954 in Machine learning

Custom license

36KB
786 lines

openai_client

crates.io Continuous integration

openai_client provides configuration, models an a http client for working with the API of OpenAi in Rust.

Cargo

[dependencies]
openai_client = "0.1.0"

Or via git:

[dependencies.redis_ts]
git = "https://github.com/tompro/openai_client.git"

Usage

use openai_client::*;

// Create client
let client = OpenAiClient::new(OpenAiConfig::new("<ACCESS_TOKEN>"));

// Create request
let request = EditRequestBuilder::default()
   .model("text-davinci-edit-001")
   .input("What day of the wek is it?")
   .instruction("Fix the spelling mistakes")
   .build()
   .unwrap();

// Send request
let result = client.create_edit(request).await?;

Features

  • Models
  • Completions
  • Edits
  • Images
    • Create
    • Edit
    • Variations
  • Embeddings
  • Files
  • Fine Tunes
  • Moderations
  • Engines
  • Parameter details

Dependencies

~6–17MB
~256K SLoC