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 {
2121 pub http_client : reqwest:: Client ,
2222 pub base_url : String ,
2323 pub api_key : String ,
24+ pub organization : Option < String > ,
2425}
2526
2627impl Client {
@@ -29,6 +30,16 @@ impl Client {
2930 http_client : reqwest:: Client :: new ( ) ,
3031 base_url : OPENAI_API_V1_ENDPOINT . to_string ( ) ,
3132 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) ,
3243 }
3344 }
3445
@@ -46,6 +57,10 @@ impl Client {
4657 . header ( reqwest:: header:: CONTENT_TYPE , content_type)
4758 . bearer_auth ( & self . api_key ) ;
4859
60+ if let Some ( organization) = & self . organization {
61+ request = request. header ( "OpenAI-Organization" , organization) ;
62+ }
63+
4964 if is_beta_feature ( path) {
5065 request = request. header ( "OpenAI-Beta" , "assistants=v1" ) ;
5166 }
You can’t perform that action at this time.
0 commit comments