Overview
Intelligence Space uses the Google Gemini API to generate contextual relationships and expand the knowledge graph. You’ll need to obtain an API key from Google Cloud Platform and configure it in your local environment.Getting Your Gemini API Key
Access Google AI Studio
Navigate to Google AI Studio to create your API key.
You’ll need a Google account to access AI Studio. If you don’t have one, create it at accounts.google.com.
Create an API key
- Click “Get API Key” or “Create API Key”
- Select an existing Google Cloud project or create a new one
- Copy the generated API key to your clipboard
Review API quotas
Check your API quota limits in the Google Cloud Console.The Gemini 2.5 Flash model used by Intelligence Space has generous free tier limits suitable for development.
Configuring Environment Variables
Create .env.local file
In the root directory of your Intelligence Space project, create a new file named
.env.local:Add your API key
Open Replace
.env.local and add your Gemini API key:your_api_key_here with the actual API key you copied from Google AI Studio.Environment Variable Reference
Intelligence Space uses the following environment variable:| Variable | Required | Description |
|---|---|---|
GEMINI_API_KEY | Yes | Your Google Gemini API key for accessing the Gemini 2.5 Flash model |
Fallback Behavior
If theGEMINI_API_KEY is not configured:
- The application will start successfully
- The 3D visualization interface will load normally
- Graph expansion will fail when you try to explore a concept
- You’ll see an error indicating the API key is missing
Security Best Practices
Never commit .env.local
Always keep
.env.local in your .gitignore file. Never commit API keys to version control.Use separate keys
Use different API keys for development, staging, and production environments.
Rotate keys regularly
Periodically generate new API keys and revoke old ones in Google Cloud Console.
Monitor usage
Regularly check your API usage in Google Cloud Console to detect any unauthorized access.
Server-Side Security
Intelligence Space uses Next.js Server Actions to call the Gemini API. Your API key is never exposed to the client browser, ensuring it remains secure.
actions.ts, which runs exclusively on the server (Node.js runtime). This architecture:
- Prevents API key exposure in client-side JavaScript
- Reduces latency by processing requests server-side
- Enables request validation and rate limiting
Troubleshooting
API key not found error
API key not found error
If you see “API key not found” errors:
- Verify
.env.localexists in the project root (not in subdirectories) - Check the variable name is exactly
GEMINI_API_KEY(case-sensitive) - Restart the development server after adding the key:
- Ensure there are no spaces around the
=sign
Invalid API key error
Invalid API key error
If your API key is rejected:
- Verify you copied the complete key from Google AI Studio
- Check the key hasn’t been revoked in Google Cloud Console
- Ensure the Generative Language API is enabled for your project
- Generate a new key if necessary
Rate limit exceeded
Rate limit exceeded
If you hit rate limits:
- Check your current quota usage in Google Cloud Console
- Wait for the quota to reset (usually per minute or per day)
- Consider requesting a quota increase for production use
- Implement client-side rate limiting to reduce API calls
Environment variable not loading
Environment variable not loading
If changes to
.env.local aren’t taking effect:- Restart the Next.js development server completely
- Verify the file is in the project root directory
- Check for syntax errors (no quotes needed around the value)
- Clear Next.js cache:
Next Steps
With your API key configured, you’re ready to start using Intelligence Space! Learn more about:- Quickstart Guide - Launch your first knowledge graph
- 3D Visualization - Learn core features and interactions
- AI Expansion - Understand how Gemini generates sub-interests