Skip to content

Commit b9068b2

Browse files
authored
Let Bearer token come from reqwest::Client when config is empty.
1 parent a0a9ae0 commit b9068b2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

async-openai/src/config.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,17 @@ impl Config for OpenAIConfig {
9999
self.project_id.as_str().parse().unwrap(),
100100
);
101101
}
102-
103-
headers.insert(
104-
AUTHORIZATION,
105-
format!("Bearer {}", self.api_key.expose_secret())
106-
.as_str()
107-
.parse()
108-
.unwrap(),
109-
);
102+
103+
// API key can also be found in [`reqwest::Client`] headers.
104+
if !self.api_key().expose_secret().is_empty() {
105+
headers.insert(
106+
AUTHORIZATION,
107+
format!("Bearer {}", self.api_key().expose_secret())
108+
.as_str()
109+
.parse()
110+
.unwrap(),
111+
);
112+
}
110113

111114
// hack for Assistants APIs
112115
// Calls to the Assistants API require that you pass a Beta header

0 commit comments

Comments
 (0)