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
//! This crate provides an API client for communicating with OpenAI's GPT-3.5 and GPT-4 (ChatGPT) API.
//! The Api struct provides methods for sending requests and receiving responses from the API.
//!
//! # Example
//! ```rs
//! use chat_gpt_rs::prelude::*;
//!
//! #[tokio::main]
//! async fn main() {
//! let token = Token::new("YOUR_API_KEY");
//! let api = Api::new(token);
//! let request = Request {
//! model: Model::Gpt35Turbo,
//! messages: vec![Message {
//! role: "user".to_string(),
//! content: "Hello, how's it going?".to_string(),
//! }],
//! ..Default::default()
//! };
//! let response = api.chat(request).await;
//! if let Ok(response) = response {
//! println!("{:?}", response.choices[0].message.content);
//! } else {
//! println!("Error: {:?}", response.err());
//! }
//! }
//! ```
//!
//! ## Additional Configuration
//! Additional configuration can be added to the [request::Request] struct.
//! For more information, see the [OpenAI API documentation](https://platform.openai.com/docs/api-reference/completions).