https://promptfoo.dev/ logo
Adding an API key as an env var is not working
# ❓|questions
g
I've tried all permutations of the below
Copy code
# Define providers (LLM models)
providers:
  - id: "google:gemini-2.0-flash-exp"
    config:
      temperature: 0.2
      apiKey: ${process.env.GOOGLE_API_KEY}

env:
  GOOGLE_API_KEY: ${GOOGLE_API_KEY}


GEMINI_API_KEY=key npx promptfoo eval --verbose --config tests/promptfoo.yaml
With no results. and always
Copy code
Google API response: {"error":{"code":400,"message":"API key not valid. Please pass a valid API key.","status":"INVALID_ARGUMENT","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"API_KEY_INVALID","domain":"googleapis.com","metadata":{"service":"generativelanguage.googleapis.com"}},{"@type":"type.googleapis.com/google.rpc.LocalizedMessage","locale":"en-US","message":"API key not valid. Please pass a valid API key."}]}}
Can anyone pls help? I'm using an .env file as well it's in
.
not
tests
though
i
try removing the api key in the config and set
GOOGLE_API_KEY
(not
GEMINI_API_KEY
) as an enviornment variable
Copy code
GOOGLE_API_KEY=key npx promptfoo eval --verbose --config tests/promptfoo.yaml
g
thanks @ian i've tried that too but same error
btw @Ian i've figured out that if I insert it as a raw string int he config it maybe works but none of the other methods work. but obviously i don't want to do that for security reasons