Skip to content

Commit ef1331a

Browse files
authored
fix: correctly propagate gemini API key (#1375)
1 parent a8baedb commit ef1331a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rust/cocoindex/src/llm/gemini.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,14 @@ impl LlmGenerationClient for AiStudioClient {
143143
}
144144

145145
let url = self.get_api_url(request.model, "generateContent");
146-
let resp = http::request(|| self.client.post(&url).json(&payload))
147-
.await
148-
.context("Gemini API error")?;
146+
let resp = http::request(|| {
147+
self.client
148+
.post(&url)
149+
.header("x-goog-api-key", &self.api_key)
150+
.json(&payload)
151+
})
152+
.await
153+
.context("Gemini API error")?;
149154
let resp_json: Value = resp.json().await.context("Invalid JSON")?;
150155

151156
if let Some(error) = resp_json.get("error") {

0 commit comments

Comments
 (0)