Google Gemini API Setup
LlamaCloud supports Google Gemini API for direct access to Google’s AI models with simple API key authentication. This provides a straightforward alternative to Google Vertex AI when you don’t need enterprise Google Cloud Platform features.
Prerequisites
Section titled “Prerequisites”- A valid Google account
- Google Gemini API key from Google AI Studio
- Access and quota for supported models:
- Gemini 1.5 Pro
- Gemini 1.5 Flash
- Gemini 2.0 Flash
Environment Variables
Section titled “Environment Variables”The Google Gemini API integration uses a single environment variable:
GOOGLE_GEMINI_API_KEY
- Your Google Gemini API key (required)
Configuration
Section titled “Configuration”Follow these steps to configure Google Gemini API integration:
Step 1: Get Google Gemini API Key
Section titled “Step 1: Get Google Gemini API Key”Get your API key from Google AI Studio.
Step 2: Create Kubernetes Secret
Section titled “Step 2: Create Kubernetes Secret”Create a secret with your Google Gemini API key:
apiVersion: v1kind: Secretmetadata: name: gemini-credentialstype: OpaquestringData: GOOGLE_GEMINI_API_KEY: "your-api-key-here"
Apply the secret:
kubectl apply -f gemini-secret.yaml
Step 3: Configure Helm Values
Section titled “Step 3: Configure Helm Values”Reference the secret in your Helm configuration:
# External SecretllamaParse: config: existingGeminiApiKeySecret: "gemini-credentials"
# or direct configurationllamaParse: config: geminiApiKey: "your-api-key-here"
Verification
Section titled “Verification”After configuration, verify your Google Gemini integration:
-
Verify in Admin UI: Check available Google models in LlamaCloud admin interface
-
Test functionality: Upload a document to confirm Gemini models are working
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”API Key Invalid
Section titled “API Key Invalid”Error: API key not valid
Solution:
- Ensure your API key is correctly set and hasn’t expired
- Verify the key is from Google AI Studio
- Check that the API key has proper permissions
Quota Exceeded
Section titled “Quota Exceeded”Error: Quota exceeded
Solution:
- Check your Google AI Studio quotas and usage limits
- Consider upgrading your plan or requesting quota increases
- Monitor API usage to avoid rate limiting
Model Access Issues
Section titled “Model Access Issues”Error: Model not found or access denied
Solution:
- Verify the model is available in your region
- Check if you have access to the specific model
- Ensure your API key has model access permissions
Debug Steps
Section titled “Debug Steps”-
Test Gemini API directly:
Terminal window curl -H "Content-Type: application/json" \-H "x-goog-api-key: YOUR_API_KEY" \-d '{"contents":[{"parts":[{"text":"Hello"}]}]}' \"https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent" -
Verify secret mounting:
Terminal window kubectl get secret gemini-credentials -o yamlkubectl describe pod <pod-name> | grep -A 20 Environment -
Check network connectivity: Ensure your cluster can reach
generativelanguage.googleapis.com