Overview
Argument Cartographer integrates with multiple external APIs. This guide helps you diagnose and resolve API-related errors based on actual error handling in the codebase.Firecrawl API Errors
Error: “Firecrawl API key not configured”
Full error message:src/ai/tools/web-search.ts:58, src/ai/tools/web-scraper.ts:25
Validation code:
Get Valid API Key
- Go to Firecrawl
- Sign up or log in
- Navigate to API Keys section
- Generate a new key
- Copy the key (starts with
fc-)
Error: “Firecrawl Search Failed”
Symptom: Console shows[Firecrawl Search] Failed: 402 or [Firecrawl Search] Failed: 429
Status codes:
Your Firecrawl account has run out of credits.Solution: Add credits to your Firecrawl account or upgrade plan.
Too many requests in a short time period.Solution:
- Implement rate limiting in your application
- Upgrade to higher tier for increased limits
- Wait and retry after cooldown period
API key is invalid or revoked.Solution: Generate a new API key.
- Tries targeted search with trusted news outlets
- Falls back to general search if targeted search fails
- Falls back to search snippets if scraping fails
- Enters limited analysis mode if all APIs fail
These fallbacks ensure the application continues to function even when Firecrawl credits are depleted.
Error: “Content too short”
Console output:[Firecrawl] Content too short for {url}
Cause: Scraped markdown is less than 100 characters.
Validation code:
- URL is a login page or paywall
- Content is behind JavaScript rendering
- Website blocks Firecrawl’s user agent
- URL returns 404 or redirect
Twitter API Errors
Error: “TWITTER_BEARER_TOKEN is not configured”
Full error message:src/ai/tools/twitter-search.ts:49
Validation code:
Get Twitter API Access
- Go to Twitter Developer Portal
- Create a new project or select existing
- Create an app within the project
- Navigate to app settings
Generate Bearer Token
- Go to Keys and tokens tab
- Under Authentication Tokens, generate Bearer Token
- Copy the token immediately (it won’t be shown again)
- Store securely in
.envfile
Error: Twitter API 401 Unauthorized
Symptom:Twitter API request failed with status 401
Causes:
Invalid Bearer Token
Invalid Bearer Token
Token is incorrect, expired, or revoked.Solution:
- Regenerate bearer token in Twitter Developer Portal
- Update environment variable
- Redeploy application
Missing Authorization Header
Missing Authorization Header
App Permissions
App Permissions
Verify your Twitter app has required permissions:
- Go to Developer Portal → Your App → Settings
- Check App permissions
- Must have at least Read access
- Save changes and regenerate tokens if changed
Error: Twitter API 429 Rate Limit
Symptom:Twitter API request failed with status 429
Twitter API v2 rate limits:
Rate limit: 180 requests per 15-minute window (per user)Application usage:
- 1 request per argument analysis
- Max 20 tweets returned per request
Handle Rate Limit Gracefully
The application already handles this as a non-fatal error:Analysis continues without social pulse data.
No Tweets Found (Empty Result)
Symptom: Twitter search returns empty array[]
This is not an error — it’s a valid response when no tweets match the query.
Validation code:
- Topic is too niche or recent
- Search query filters out all results
- Language filter (
lang:en) excludes relevant tweets - Query uses operators that are too restrictive
Google Gemini API Errors
Model Not Available
Symptom: “Model ‘gemini-1.5-pro’ not available” or 404 errors. Causes:- API key doesn’t have access to Gemini 1.5 Pro
- Model name is incorrect
- Region restrictions
Verify Model Access
- Go to Google AI Studio
- Test your API key with Gemini 1.5 Pro
- Ensure your project has access to the model
Safety Filter Triggered
Symptom: AI refuses to respond or returns empty content. Error message:- Hate speech
- Sexually explicit content
- Harassment
- Dangerous content
- Rephrase input: Avoid potentially sensitive topics or rephrase neutrally
- Review source content: Scraped articles may contain filtered content
- Adjust safety settings: Configure in Genkit AI config (use with caution)
Token Limit Exceeded
Symptom: “Input tokens exceed maximum context length” Gemini 1.5 Pro limits:- Context window: 1 million tokens (~700,000 words)
- Output limit: 8,192 tokens
-
Reduce number of sources:
- Implement chunking: Split large analyses into multiple AI calls
- Summarize sources first: Use a separate flow to summarize each source before main analysis
Error Response Patterns
Standard Error Object
All API errors follow this pattern:Logging Best Practices
The application logs errors with context:All errors are logged to console. Check Vercel function logs for detailed error traces.
Testing API Integrations
Test Firecrawl
title, url, description.
Test Twitter API
data array containing tweet objects.
Test Google Gemini
candidates[0].content.parts[0].text.
Debugging Checklist
Test Each API Independently
Use the curl commands above to verify each API works outside your application.
Check Vercel Environment Variables
Ensure variables are:
- Added to correct environment (Production/Preview)
- Spelled exactly as expected
- Not containing extra spaces or quotes
Monitor API Usage
- Firecrawl: Check dashboard for credit balance
- Twitter: Monitor rate limit headers
- Google: Review Cloud Console quotas
Next Steps
Common Issues
General troubleshooting guide
Performance
Optimize API call performance
Environment Variables
Complete environment variable reference
Firebase Setup
Configure Firebase integration
