Skip to main content
Gemini CLI is a powerful command-line interface tool that provides direct access to Google’s Gemini AI models from your terminal. It offers intelligent code generation, natural language processing, and development assistance capabilities. By integrating Gemini CLI with Unbound Security AI Gateway, you can leverage these AI capabilities while maintaining enterprise-grade security, cost control, and compliance.

Prerequisites

Before setting up the integration, ensure you have:
  • Node.js: Version 20 or higher installed on your system
  • Unbound Application: A configured application in your Unbound Security dashboard

Installation

Step 1: Install Gemini CLI

Install the Gemini CLI globally using npm:
npm install -g @google/gemini-cli

Step 2: Configure Environment Variables

To set up your environment to point Gemini CLI to Unbound AI Gateway, run the following command in your terminal:
python3 <(curl -fsSl https://raw.githubusercontent.com/websentry-ai/setup/refs/heads/main/gemini-cli/gateway/setup.py) --domain gateway.getunbound.ai
If your Unbound Gateway URL changes, you can update it in the command above by replacing gateway.getunbound.ai Once the script starts, it will generate a login URL. Click the URL or open it in your browser. The page will automatically:
  • Authenticate your account through the Unbound dashboard.
  • Retrieve and register your gateway credentials.
  • Redirect you back to a success page.
You can close the browser window once the callback is complete. Return to your terminal. The installation will finish automatically.

Step 3: First-Time Setup

When you open Gemini CLI for the first time after setup, you’ll be prompted with: “How would you like to authenticate for this project?” You’ll see three options:
  1. Login with Google
  2. Use Gemini API Key
  3. Vertex AI
Below the options, you’ll see: “Existing API Key detected (GEMINI_API_KEY)” Select “Use Gemini API Key” to use the automatically configured key. When prompted to enter the API key, simply press Enter since the key is already set in your profile. Gemini CLI will then be ready to use.

Step 4: Verify Installation

Test that Gemini CLI is properly configured:
gemini --version

Usage

Basic Usage

Once configured, you can start using Gemini CLI in your terminal:
gemini
This launches the interactive Gemini interface where you can:
  • Generate code for various programming languages
  • Ask questions about development topics
  • Get assistance with debugging
  • Process and analyze text content

Example Commands

# Start interactive mode
gemini

# Generate code for a specific task
gemini "Create a Python function to sort a list"

# Ask development questions
gemini "How do I implement authentication in a web app?"

# Get help with debugging
gemini "Help me debug this JavaScript error"

Advanced Usage

# Generate code with specific parameters
gemini --model="gemini-pro" "Write a REST API in Node.js"

# Process files
gemini --input="code.py" "Explain this code"

# Generate documentation
gemini "Generate documentation for this function"

Model Selection

You can specify different Gemini models:
# Use specific model
gemini --model="gemini-pro" "Your prompt here"

# List available models
gemini --list-models

Troubleshooting

Common Issues

Gemini CLI not found after installation:
# Check if npm global bin is in your PATH
npm config get prefix
# Add to PATH if needed
export PATH="$(npm config get prefix)/bin:$PATH"
API key not recognized:
# Verify your environment variables
echo $GEMINI_API_KEY
echo $GOOGLE_GEMINI_BASE_URL
# Once the setup is complete, open gemini-cli in a new terminal
Connection issues:
  • Ensure your Unbound API key is valid
  • Check that the base URL is correct
  • Verify your internet connection
  • Confirm the Unbound service is running
Model not found:
# Check available models
gemini --list-models
# Use a different model if needed
gemini --model="gemini-pro-vision" "Your prompt"

Security Benefits

Using Gemini CLI with Unbound Security AI Gateway provides:
  • Request Monitoring: All AI requests are logged and monitored
  • Cost Control: Set spending limits and track usage across all models
  • Compliance: Ensure AI interactions meet your organization’s standards
  • Guardrails: Apply security policies to AI responses
  • Audit Trail: Complete visibility into AI usage patterns
  • Model Routing: Intelligent routing to optimize performance and costs
  • Rate Limiting: Prevent abuse and manage resource usage

Best Practices

Development Workflow

  1. Start with simple prompts to test the integration
  2. Use specific, clear instructions for better results
  3. Iterate on prompts to improve output quality
  4. Monitor usage through Unbound dashboard
  5. Set appropriate guardrails for your use case

Security Considerations

  • Keep your API keys secure and never commit them to version control
  • Use environment variables for configuration
  • Regularly rotate your API keys
  • Monitor usage patterns for anomalies
  • Set up appropriate guardrails for your organization’s needs