KeyError using Imagen 3 API via Python

In this case, you should leave API_KEY exactly as it is.
This line reads the API Key from the “API_KEY” environment variable, as suggested in an earlier step of the tutorial:

This tutorial assumes that you’re accessing your API key as an environment variable.

Since you’re using PowerShell, you would set the environment variable with the key using something like this:

$Env:API_KEY = "XXXXX-your-key-here-XXXXX"

in the shell before you try to run your python script.

1 Like