From acddece5205c34338ad8519ab98f2420a9ddb0dc Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 17 Mar 2023 15:09:06 +0800 Subject: feat: add `config.organization_id` (#77) --- src/client.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/client.rs') diff --git a/src/client.rs b/src/client.rs index 14d65d0..d366509 100644 --- a/src/client.rs +++ b/src/client.rs @@ -153,12 +153,18 @@ impl ChatGptClient { .and_then(|m| m.insert("stream".into(), json!(true))); } - let builder = self + let (api_key, organization_id) = self.config.read().get_api_key(); + + let mut builder = self .build_client()? .post(API_URL) - .bearer_auth(self.config.read().get_api_key()) + .bearer_auth(api_key) .json(&body); + if let Some(organization_id) = organization_id { + builder = builder.header("OpenAI-Organization", organization_id); + } + Ok(builder) } } -- cgit v1.2.3