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