Skip to main content

Overview

The GTM Research Engine integrates with multiple external APIs to gather comprehensive research data. You’ll need API keys for three services: Google Gemini (AI), Tavily (Google Search), and NewsAPI (News data).

Required API Keys

Google Gemini

AI-powered query generation and analysis

Tavily

Google Search API for web research

NewsAPI

News articles and press releases

Google Gemini API Key

1

Access Google AI Studio

Visit Google AI Studio and sign in with your Google account.
Google Gemini offers a generous free tier with up to 60 requests per minute.
2

Create API Key

  1. Click on “Get API Key” in the top navigation
  2. Select “Create API key in new project” or choose an existing project
  3. Copy the generated API key
Store your API key securely. Never commit it to version control or share it publicly.
3

Add to Environment

Add the key to your backend/.env file:
.env
GEMINI_API_KEY=AIzaSyD...
4

Verify Configuration

Test the API key:
cd backend
python -c "import os, google.generativeai as genai; genai.configure(api_key=os.getenv('GEMINI_API_KEY')); print('Gemini API configured successfully')"

Gemini API Details

The GTM Research Engine uses Google Gemini 2.5 Flash for:
  • Query Generation: Creating intelligent search strategies based on research goals
  • Confidence Scoring: Evaluating the relevance and quality of search results
  • Technology Extraction: Identifying technologies and tools from evidence
  • Result Analysis: Summarizing and contextualizing findings
Free Tier:
  • 15 requests per minute
  • 1,500 requests per day
  • 1 million requests per month
Paid Tier:
  • Higher rate limits available
  • Pay-per-request pricing
  • See Google AI Pricing for details
The default configuration uses 2,000 RPM. Adjust gemini_rpm in config.py to match your tier.

Tavily API Key

1

Sign Up for Tavily

Visit Tavily and create a free account.
Tavily provides a powerful Google Search API optimized for AI applications.
2

Get API Key

  1. Navigate to your Tavily Dashboard
  2. Copy your API key from the dashboard
  3. Note your plan’s rate limits
3

Add to Environment

Add the key to your backend/.env file:
.env
TAVILY_API_KEY=tvly-...
4

Test Connection

Verify the API key works:
cd backend
python -c "from tavily import TavilyClient; import os; client = TavilyClient(api_key=os.getenv('TAVILY_API_KEY')); print('Tavily API configured successfully')"

Tavily API Details

The GTM Research Engine uses Tavily for:
  • Site-specific searches: Searching within company domains
  • Boolean queries: Complex search strategies with AND/OR operators
  • File type filtering: Finding PDFs, presentations, and documents
  • News searches: Recent articles and announcements
  • Deep web access: More comprehensive than standard search APIs
Free Tier:
  • 1,000 API calls per month
  • 5 requests per second
Starter Plan ($50/month):
  • 10,000 API calls per month
  • 10 requests per second
Pro Plan ($200/month):
  • 100,000 API calls per month
  • 20 requests per second
The default configuration expects 500 RPM. For the free tier, reduce tavily_rpm in config.py to avoid rate limiting.

NewsAPI Key

1

Register for NewsAPI

Visit NewsAPI and create a free account.
NewsAPI provides access to news articles from over 150,000 sources worldwide.
2

Get API Key

  1. Complete the registration form
  2. Verify your email address
  3. Copy your API key from the confirmation page or account page
3

Add to Environment

Add the key to your backend/.env file:
.env
NEWS_API_KEY=abc123...
4

Verify Setup

Test the NewsAPI connection:
cd backend
python -c "from newsapi import NewsApiClient; import os; client = NewsApiClient(api_key=os.getenv('NEWS_API_KEY')); print('NewsAPI configured successfully')"

NewsAPI Details

The GTM Research Engine uses NewsAPI for:
  • Press releases: Company announcements and product launches
  • Funding news: Investment rounds and acquisitions
  • Partnership announcements: Strategic collaborations
  • Security incidents: Breach notifications and security updates
  • Industry coverage: Market trends and competitive intelligence
Developer Plan (Free):
  • 100 requests per day
  • 1,000 requests per month
  • Articles up to 30 days old
  • Development/testing only
Business Plan ($449/month):
  • 250,000 requests per month
  • All historical articles
  • Commercial use allowed
For production use, consider upgrading to the Business plan. The free tier is suitable for development and testing.

Complete Configuration Example

Here’s a complete .env file example with all required API keys:
.env
# ========================================
# GTM Research Engine - Backend Configuration
# ========================================

# Required API Keys
GEMINI_API_KEY=AIzaSyD1234567890abcdefghijklmnopqrstuv
TAVILY_API_KEY=tvly-1234567890abcdefghijklmnopqrstuv
NEWS_API_KEY=abc123def456ghi789jkl012mno345pqr678

# Optional: Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0

# Optional: Server Configuration
BACKEND_HOST=0.0.0.0
BACKEND_PORT=8000
BACKEND_RELOAD=true

# Optional: CORS Settings
ALLOWED_ORIGINS=http://localhost:3000

# Optional: Logging
LOG_LEVEL=INFO
Security Best Practices:
  • Never commit .env files to version control
  • Add .env to your .gitignore file
  • Use different API keys for development and production
  • Rotate keys regularly
  • Use environment-specific key management in production (AWS Secrets Manager, etc.)

Validation & Testing

After configuring all API keys, validate your setup:
cd backend
python -c "
import os
from dotenv import load_dotenv

load_dotenv()

keys = {
    'GEMINI_API_KEY': os.getenv('GEMINI_API_KEY'),
    'TAVILY_API_KEY': os.getenv('TAVILY_API_KEY'),
    'NEWS_API_KEY': os.getenv('NEWS_API_KEY'),
}

for name, value in keys.items():
    status = '✓ Set' if value else '✗ Missing'
    print(f'{status} {name}')
"

Cost Management

Optimize API Usage:
  • Start with search_depth: "quick" for testing
  • Use max_parallel_searches: 1-3 to reduce concurrent requests
  • Set appropriate confidence_threshold to filter low-quality results
  • Monitor your API usage through provider dashboards

Expected API Usage

For a typical research request with 5 companies:

Gemini

~10-20 requests
Query generation + confidence scoring

Tavily

~20-100 requests
Depends on search depth and companies

NewsAPI

~5-25 requests
One per company + depth level

Troubleshooting

Error: ValueError: GEMINI_API_KEY environment variable is requiredSolutions:
  1. Verify .env file exists in the backend directory
  2. Check for typos in environment variable names
  3. Ensure .env is loaded (use python-dotenv)
  4. Restart the backend server after adding keys
# Verify .env file
cat backend/.env | grep API_KEY
Error: 429 Too Many Requests or similar rate limit errorsSolutions:
  1. Reduce max_parallel_searches in requests (try 1-3)
  2. Lower rate limits in config.py to match your API tier
  3. Add delays between requests
  4. Upgrade to a higher API tier
config.py
# For free tier NewsAPI
newsapi_rpm = 10  # Very conservative

# For free tier Tavily
tavily_rpm = 60   # 1 per second
Error: 401 Unauthorized or Invalid API KeySolutions:
  1. Verify you copied the complete API key
  2. Check for extra spaces or newlines
  3. Regenerate the API key if necessary
  4. Ensure the key is active (not expired or revoked)
# Check for whitespace issues
python -c "import os; key=os.getenv('GEMINI_API_KEY'); print(f'Length: {len(key)}, Has spaces: {' ' in key}')"

Next Steps

Start the Application

Run the backend and frontend servers

API Reference

Explore available endpoints and features

Build docs developers (and LLMs) love