https://ai.google.dev/gemini-api/docs/api-key#macos---zsh
For initial testing, you can hard code an API key, but this should only be temporary since it is not secure. The rest of this section goes through how to set up your API key locally as an environment variable with different operating systems.
Zsh is a common Linux and macOS terminal configuration. You can check if you have a configuration file for it by running the following command:
~/.zshrc
If the response is "No such file or directory", you will need to create this file and open it by running the following commands, or use bash:
touch ~/.zshrc
open ~/.zshrc
Next, you need to set your API key by adding the following export command:
export GEMINI_API_KEY=<YOUR_API_KEY_HERE>
After saving the file, apply the changes by running:
source ~/.zshrc