Overview
Argument Cartographer integrates with three primary external services to gather data and generate intelligence. Each integration follows specific patterns for reliability, cost optimization, and graceful degradation.Design Philosophy: Fail gracefully - if an external API is unavailable, provide degraded but functional service rather than complete failure.
Integration Architecture
Firecrawl Integration
Overview
Service: Firecrawl Purpose: Web search and content scraping API Version: v1 Cost:- Free tier: 500 requests/month
- Pro: $29/mo for 10,000 requests
Search Endpoint
Trusted Outlets Filter
Strategy: Prioritize quality journalismScraping Endpoint
Error Handling
- Rate Limiting
- Quota Exceeded
- Scraping Failure
HTTP 429: Too Many RequestsStrategy:
Twitter API Integration
Overview
Service: Twitter API v2 Purpose: Social sentiment and public discourse Authentication: Bearer Token (OAuth 2.0) Cost:- Free tier: 500,000 tweets/month read
- Basic ($100/mo): 10M tweets/month
Search Endpoint
Query Construction
- Operators
- Fields
- Sorting
Language Filter:
lang:enExclude Retweets: -is:retweetHashtag: #AIregulation (automatic in query)From User: from:username (not currently used)Exclude Replies: -is:reply (not currently used)Error Handling
Rate Limit (429)
Rate Limit (429)
Limit: 450 requests per 15-minute windowResponse Headers:Handling:
No Results
No Results
Scenario: Topic has no recent tweetsResponse:
{ data: [] }Handling:Auth Failure (401)
Auth Failure (401)
Cause: Invalid or missing Bearer TokenHandling:
Google Gemini Integration
Overview
Service: Google Gemini API (via Genkit) Purpose: LLM inference for analysis, fallacy detection, summarization Model:gemini-2.5-flash
Cost:
- Free tier: 15 RPM, 1M tokens/min
- Paid: 0.30 per 1M output tokens
Configuration
API Calls
- Simple Generation
- Structured Output
- With System Prompt
Rate Limiting
Free Tier Limits:- 15 requests per minute (RPM)
- 1M tokens per minute (TPM)
- 1,500 requests per day (RPD)
Error Handling
Quota Exceeded (429)
Quota Exceeded (429)
Message: “Resource has been exhausted”Handling:
Content Filter (400)
Content Filter (400)
Cause: Input/output triggered safety filterResponse: “Blocked by safety filter”Handling:
Token Limit (400)
Token Limit (400)
Cause: Input exceeds 1M tokensHandling:
Integration Resilience
Graceful Degradation Matrix
| Service Down | Fallback Strategy | User Experience |
|---|---|---|
| Firecrawl | Use AI knowledge only | ”Sources unavailable” disclaimer |
| Skip social pulse | No Social Pulse panel shown | |
| Gemini | Queue retry, then fail | Error message + retry button |
| Firecrawl + Twitter | AI knowledge mode | Limited but functional analysis |
| All APIs | Hard fail | ”Service temporarily unavailable” |
Health Checks
Cost Monitoring
Usage Tracking
Cost Estimation
Per Analysis:- Firecrawl: 1 search + 8 scrapes = 9 requests (~$0.027 on Pro tier)
- Twitter: 1 search = 1 request (~$0.00002)
- Gemini: ~25K input tokens + ~2K output = $0.0025
- 100 analyses/day = $90/month
- 500 analyses/day = $450/month
Next Steps
AI Orchestration
How AI calls are orchestrated across these APIs
Configuration
Configure API keys and rate limits
Installation
Set up API credentials for your instance
Troubleshooting
Common API errors and solutions
