diff --git a/src/v1/api.rs b/src/v1/api.rs index 9d80657..9667839 100644 --- a/src/v1/api.rs +++ b/src/v1/api.rs @@ -168,11 +168,8 @@ impl OpenAIClient { let mut request = client.request(method, url); - if self.api_key.is_some() { - request = request.header( - "Authorization", - format!("Bearer {}", self.api_key.as_ref().unwrap()), - ); + if let Some(api_key) = &self.api_key { + request = request.header("Authorization", format!("Bearer {}", api_key)); } if let Some(organization) = &self.organization {