This guide will help you set up the AI-powered matching feature using Google's Gemini API.
- A Google account
- Access to Google AI Studio (free)
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated API key
Add the API key to your environment:
export GEMINI_API_KEY="your-actual-api-key-here"For development, add it to your .env file in the backend directory:
GEMINI_API_KEY=your-actual-api-key-hereStart your Flask application and test the matching endpoint:
cd backend
flask runThen make a request to test AI matching:
curl http://localhost:5000/matches/1You should see a response like:
{
"matches": [
{
"id": 2,
"name": "Jane",
"email": "jane@gmail.com",
"offer_matches": ["music matches music theory", "cooking matches cooking"],
"learn_matches": ["python matches programming"]
}
],
"count": 1,
"ai_enabled": true
}Check that AI matching is enabled by looking for "ai_enabled": true in the response. If you see "ai_enabled": false, the API key is not properly configured.
With AI matching enabled, your app will now:
- Checks skill compatibility: Uses AI to determine if skills are related (e.g., "piano" and "music theory")
- Finds bidirectional matches: Ensures both users can benefit from the exchange
- Returns match details: Shows exactly which skills matched for transparency
- Falls back to exact matching if AI calls fail
- Make sure you've set the
GEMINI_API_KEYenvironment variable correctly - Restart your Flask application after setting the environment variable
- Check that the API key is valid and has proper permissions
- The system includes rate limiting (0.1 second delay between calls)
- If the API is unavailable, the app falls back to exact matching
- No functionality is lost, just enhanced features are disabled
- Users will still find matches, but only with identical skill names