The GitHub project link is as follows:
The usage instructions are detailed in the README file. This article focuses on the motivations behind creating this project and some specific details.
This project was entirely coded by AI. To have the AI produce code that meets my expectations, I realized that drafting comprehensive and detailed prompts and engaging in iterative improvements with it is a rather demanding task.
Background and Motivation
OpenRouter / SiliconFlow / DeepSeek Detection
As early as last year, with new users registering for SiliconFlow receiving bonuses, many individuals in forums shared API keys. At that time, I found the need for batch testing the usability of API keys. Initially, I manually tested each key by copying it into software and sending actual requests to verify usability.
As the number of API keys increased, manual testing became inefficient. I then had the AI compose a Bash script utilizing curl and jq for detection. Later, numerous OpenRouter free API keys were shared, and I also scraped many from GitHub. I adapted the script to test against OpenRouter endpoints. Similarly, this was done for DeepSeek testing scripts.
Gemini API Detection
Unlike now, where free quotas for Gemini Free Tier are nearly unusable due to severe cuts, Gemini’s generous quotas last year led to a phenomenon in forums called “wild foraging.” This involved scanning GitHub for intentionally or unintentionally exposed Google Cloud API keys (starting with AIzaSy) and pooling them to invoke Gemini services.
Although I didn’t engage in “wild foraging” back then, after Google’s drastic quota cuts, my existing API keys became insufficient. I started searching for new ones, finding over a hundred in forums alone. I also had AI write a detection script for them: first obtaining model lists to perform preliminary checks, then adding deep detection for produce-generation to avoid unusable keys despite appearing valid.
At the time, OpenCode or similar AI programming tools were unavailable. I collaborated through conversations with AI to refine scripts, which were basic—lacking deduplication or retry mechanisms—processing keys in sequence and summarizing results.
Turning Point
A turning point came while exploring old forum threads on “wild foraging”. I discovered a file containing over 100,000 Gemini API keys. Using my old scripts would’ve taken days, accounting for testing failures caused by network fluctuations. With the maturity of AI programming tools, I opted to rewrite scripts in Python, adding more features and avoiding dependencies like curl or jq.
Batch Detection for OpenRouter / SiliconFlow / DeepSeek
Starting with less complex OpenRouter / SiliconFlow / DeepSeek API key batch detection scripts, I categorized detected results into four classes: positive credit balance, zero balance, unusable, and testing fails.
The scripts supported API key lists from files and direct input for few or single keys. For varied input formats, keys could be separated using spaces, newlines, ,, ;, /, |, or &. Automated deduplication was added to prevent repeated tests of the same keys.
Considering testing durations may encounter network disruptions, I integrated automatic retries for connection issues and TCP session reuse to expedite testing. Results by default output to the terminal but could be written to files via the --report parameter, with separators adjustable using --sep (changeable for files but consistently comma-separated in terminal output).
Gemini API Detection
Basic Detection for Gemini API Keys
With Gemini keys surpassing 100,000, even with TCP reuse, testing in linear time remains impractical. Multi-threading was employed for concurrent preliminary checks.
Multi-threading alone, however, was insufficient. Thus, local caching of API key states optimized subsequent testing: invalidated keys were skipped, while valid keys underwent rechecks by default or forced rechecks with the --force parameter. Testing queues cached valid keys for retries, ensuring efficiency and prolonged utility.
Custom features included atomic writes for interrupt-resilience, automated suspensions when IP issues arose, and resilient retries on encountering API service errors like 503 responses. Preliminary checks categorized numerous keys—detecting leaked, expired, or invalid states—culminating in approximately 15,000 potentially valid keys after filtering.
Deep Detection for Gemini API Keys
Deep testing utilized generateContent for actual results generation, transitioning from multithreading to safer single-threaded operations to avoid potential blacklisting. It defaulted to the gemini-2.5-flash-lite model, with options for others. Invalid initial states cached from basic checks vastly filtered eventual deep verification, identifying merely thirty usable keys—a reflection of rare practical availability.
Usability Tests Across Gemini Models and Methods
Further script refinements targeted method-specific evaluations across all Gemini models, accounting for extensive functional disparities. Challenges arose in constructing minimal yet valid request bodies per model, with significant trial adjustments necessary.
To summarize, practical usability encompassed embedding models or dialogues supporting generateContent and embedContent, accommodating varied input nuances, comprehensive reporting adjustments, and debugging anomalies from restricted, limited, or redundant setups.
Google API Errors Overview
Diverse error returns from Google API interactions offered considerable insights. The compilation, from invalid credentials to inappropriate quota configurations and debugging constraints, challenges robust exception handling prioritization. Certain Gemini API idiosyncrasies complicate reliance on documentation fidelity, necessitating proactive incident reporting or alternative scenario navigation.
Final Thoughts
This article grew into a verbose explanation unintentionally. Reflecting on these cumulative insights and writing enhancements reveals ongoing refinement opportunities to optimize scaleable API key utilities.