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