GenkitG
Genkitโ€ข11mo ago
ripe-gray

im having some trouble getting genkit to

im having some trouble getting genkit to work when running the following command: genkit start -- node index.js

unless i paste my api key directly into the following code like so:

const ai = genkit({
plugins: [
googleAI({ apiKey: "XXXXXXXXXX" })],
model: "gemini-1.5-flash",

});

it doesnt work.

If I try it this way:

const { defineSecret } = require("firebase-functions/params");
const geminiApiKey = defineSecret("GEMINI_API_KEY");

const ai = genkit({
plugins: [
googleAI({ apiKey: geminiApiKey.value() })],
model: "gemini-1.5-flash",

});

i get the following error:

{"severity":"WARNING","message":"No value found for secret parameter "GEMINI_API_KEY". A function can only access a secret if you include the secret in the function's dependency array."}

yet when I check the secret for that value with: firebase functions:secrets:access GEMINI_API_KEY it returns the correct API key.

What am I doing wrong here?
Was this page helpful?