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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Dify client library.
//!
//! # Examples
//!
//! ## Client with single api key
//!
//! ```no_run
//! use dify_client::{request, Config, Client};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() {
//! let config = Config {
//! base_url: "https://api.dify.ai".into(),
//! api_key: "API_KEY".into(),
//! timeout: Duration::from_secs(60),
//! };
//! let client = Client::new_with_config(config);
//!
//! // Use the client
//! let data = request::ChatMessagesRequest {
//! query: "What are the specs of the iPhone 13 Pro Max?".into(),
//! user: "afa".into(),
//! ..Default::default()
//! };
//! let result = client.api().chat_messages(data).await;
//! println!("{:?}", result);
//! }
//! ```
//!
//! ## Client with multiple api keys
//!
//! ```no_run
//! use dify_client::{http::header, request, Config, Client};
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() {
//! let config = Config {
//! base_url: "https://api.dify.ai".into(),
//! api_key: "API_KEY_DEFAULT".into(),
//! timeout: Duration::from_secs(100),
//! };
//! // The client can be safely shared across multiple threads
//! let client = Client::new_with_config(config);
//!
//! // Use the client
//! let data = request::ChatMessagesRequest {
//! query: "What are the specs of the iPhone 13 Pro Max?".into(),
//! user: "afa".into(),
//! ..Default::default()
//! };
//! // Reuse the client with a new api key
//! let mut api = client.api();
//! let result = api.chat_messages(data.clone()).await;
//! println!("{:?}", result);
//! // Override the api key
//! api.before_send(|mut req| {
//! // rewrite the authorization header
//! let mut auth = header::HeaderValue::from_static("Bearer API_KEY_OVERRIDE");
//! auth.set_sensitive(true);
//! req.headers_mut().insert(header::AUTHORIZATION, auth);
//! req
//! });
//! let result = api.chat_messages(data).await;
//! println!("{:?}", result);
//! }
//! ```
//! For more API methods, refer to the [`Api`](api/struct.Api.html) struct.
pub use *;