Get a PageSpeed Insights API Key
Free API key setup in 2 minutes. No billing required for the free tier.
Steps
1. Open Google Cloud Console
Go to console.cloud.google.com
Sign in with any Google account. You don't need a paid Google Cloud account — the PSI API has a free tier.
2. Create or Select a Project
Click the project dropdown at the top of the page:
- New users: Click "New Project", give it a name like "PSI Testing", and create
- Existing users: Select an existing project or create a new one
3. Enable the PageSpeed Insights API
- Go to APIs & Services → Library (or search "API Library" in the top search bar)
- Search for "PageSpeed Insights API"
- Click on it and press Enable
The API is now active for your project.
4. Create Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → API Key
- Copy the key that appears
Your key is ready to use immediately.
Secure Your Key
API keys can be stolen and abused. A CS student received a $55,444 bill after their key was exposed on GitHub — attackers used it to call other billable GCP APIs. Always add restrictions.
For Server-Side Use
Restrict by IP address:
- Click on your API key in the Credentials list
- Under Application restrictions, select IP addresses
- Add your server's IP address(es)
- Save
Note: IP restrictions don't work with serverless platforms (Vercel, Cloudflare Workers, AWS Lambda) since they use dynamic IPs. Use HTTP referrer restrictions or a server-side proxy instead.
For Client-Side Use
Restrict by HTTP referrer:
- Click on your API key in the Credentials list
- Under Application restrictions, select HTTP referrers
- Add your domain:
yourdomain.com/* - Save
API Restrictions (Critical)
Always limit the key to only the PSI API — this prevents the billing nightmare above:
- Under API restrictions, select Restrict key
- Choose PageSpeed Insights API from the dropdown
- Save
Test Your Key
Verify it works with a curl request:
curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://example.com&key=YOUR_API_KEY"
A successful response returns JSON with Lighthouse data. An invalid key returns:
{
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key."
}
}
Quotas
| Limit | Value |
|---|---|
| Requests per day | 25,000 |
| Requests per minute | ~240 |
| Requests per 100 seconds per user | 60 |
Monitor usage at APIs & Services → PageSpeed Insights API → Quotas.
The daily limit resets at midnight Pacific Time. Note: Google doesn't officially publish rate limits in their documentation. These values are from third-party testing and community reports. Your actual limits may vary.
Set up quota alerts: Go to IAM & Admin → Quotas & System Limits → find PageSpeed Insights API → Create usage alert at 50%, 80%, and 95% thresholds.
For higher limits: Create multiple GCP projects (each gets its own 25k/day quota) or request a quota increase in the Quotas section. Google is reportedly reasonable about increases for legitimate use cases.
Next Steps
Skip the API Key Dance
Unlighthouse runs Lighthouse locally — no API keys, no quotas, no Google Cloud Console.
npx unlighthouse --site https://your-site.com