- For future sessions you can add this to your shell's configuration file, or use a `.env` file in your project's hierarchy
3. Run with: `npx https://github.com/google-gemini/gemini-cli#early-access`
4. Enjoy
## Examples
Once the CLI is running, you can start interacting with Gemini. Try a simple query:
```
> How can I build a web app?
```
Or ask it to perform a task using its tools:
```
> List files in the current directory.
```
## API Key Setup
The Gemini CLI requires a Gemini API Key. It supports several ways to authenticate with Google's AI services. You'll need to configure **one** of the following methods:
Or add it to your `.env` file (in project directory or user home) or shell's configuration file (like `~/.bashrc`, `~/.zshrc`, or `~/.profile`) for persistence:
echo 'export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"' >> ~/.bashrc # Or your preferred shell config file
source ~/.bashrc # Reload the config
```
Replace `"YOUR_GEMINI_API_KEY"` with your actual key.
2.**Google API Key (Vertex AI Express Mode):**
- This key can be a general Google Cloud API key enabled for the Gemini API or Vertex AI.
- Set the `GOOGLE_API_KEY` and `GOOGLE_GENAI_USE_VERTEXAI` environment variables:
```bash
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
export GOOGLE_GENAI_USE_VERTEXAI=true
```
3.**Vertex AI (Project and Location):**
- Ensure you have a Google Cloud Project and have enabled the Vertex AI API.
- Set up Application Default Credentials (ADC). For more details, refer to the [official Google Cloud ADC documentation](https://cloud.google.com/docs/authentication/provide-credentials-adc):
```bash
gcloud auth application-default login
```
- Set the `GOOGLE_CLOUD_PROJECT`, `GOOGLE_CLOUD_LOCATION`, and `GOOGLE_GENAI_USE_VERTEXAI` environment variables: