openai_rs/
lib.rs

1/// The openai-rs crate is a Rust library for the OpenAI API.
2///
3/// The crate is a wrapper around the OpenAI API. It provides a client for the API and a set of
4/// endpoints for almost each API endpoint.
5///
6/// # Quick Start
7/// ```rust
8/// use std::borrow::Cow;
9/// use openai_rs::client::Client;
10/// use openai_rs::endpoints::edits::Edit;
11/// use openai_rs::endpoints::{Response, ResponseError};
12/// use openai_rs::openai;
13///
14/// #[tokio::main]
15/// async fn main() {
16///     // Create the Client with your API key.
17///     let client: Client = openai::new("api_key");
18///
19///     // Create the Edit struct with the input and instruction.
20///     let edit = Edit {
21///         input: Cow::Borrowed("What day of the wek is it?"),
22///         instruction: Cow::Borrowed("Fix the spelling mistakes"),
23///         ..Default::default()
24///     };
25///
26///     // Send the request to the OpenAI API.
27///     let response: Result<Response, ResponseError> = client.create(
28///         Some("text-davinci-edit-001"), &edit
29///     ).await;
30/// }
31/// ```
32///
33/// # Requirements
34/// * An api key at [OpenAI API](https://openai.com/api-docs/) for the Client.
35/// * An async runtime like [tokio](https://tokio.rs) in order to use the async functions.
36///
37
38pub mod openai;
39pub mod client;
40pub mod endpoints;
41
42#[macro_use]
43extern crate log;
44extern crate core;