File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub struct Client {
21
21
pub http_client : reqwest:: Client ,
22
22
pub base_url : String ,
23
23
pub api_key : String ,
24
+ pub organization : Option < String > ,
24
25
}
25
26
26
27
impl Client {
@@ -29,6 +30,16 @@ impl Client {
29
30
http_client : reqwest:: Client :: new ( ) ,
30
31
base_url : OPENAI_API_V1_ENDPOINT . to_string ( ) ,
31
32
api_key,
33
+ organization : None ,
34
+ }
35
+ }
36
+
37
+ pub fn new_with_organization ( api_key : String , organization : String ) -> Self {
38
+ Self {
39
+ http_client : reqwest:: Client :: new ( ) ,
40
+ base_url : OPENAI_API_V1_ENDPOINT . to_string ( ) ,
41
+ api_key,
42
+ organization : Some ( organization) ,
32
43
}
33
44
}
34
45
@@ -46,6 +57,10 @@ impl Client {
46
57
. header ( reqwest:: header:: CONTENT_TYPE , content_type)
47
58
. bearer_auth ( & self . api_key ) ;
48
59
60
+ if let Some ( organization) = & self . organization {
61
+ request = request. header ( "OpenAI-Organization" , organization) ;
62
+ }
63
+
49
64
if is_beta_feature ( path) {
50
65
request = request. header ( "OpenAI-Beta" , "assistants=v1" ) ;
51
66
}
You can’t perform that action at this time.
0 commit comments