Upload free_keys.csv with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import osimport csvimport randomimport subprocessimport requests# Direct raw link to your uploaded CSV fileRAW_URL = "https://huggingface.co/datasets/ppsinghkhush3/free_apis/raw/main/free_keys.csv"print(f"📡 Streaming live dataset from Hugging Face endpoint...")try:# 1. Fetch the raw file content directly over HTTPresponse = requests.get(RAW_URL, timeout=10)if response.status_code == 404:raise Exception("File not found on remote server. Make sure free_keys.csv is spelled right.")elif response.status_code != 200:raise Exception(f"Hugging Face server responded with status code: {response.status_code}")# 2. Parse the text stream directly into a CSV reader dictionarycsv_lines = response.text.splitlines()reader = csv.DictReader(csv_lines)key_pool = []# 3. Collect credentials into local memory arrayfor row in reader:# Match whatever column headers exist by cleaning keysrow_clean = {k.lower().strip() if k else "": v.strip() for k, v in row.items()}provider = row_clean.get("provider") or row_clean.get("name") or row_clean.get("type")api_key = row_clean.get("api_key") or row_clean.get("key") or row_clean.get("token")# If headers didn't match, fall back to index columnsif not provider or not api_key:values = list(row.values())if len(values) >= 2:provider, api_key = values[0].strip(), values[1].strip()if provider and api_key and len(api_key) > 10 and not api_key.startswith("your-"):key_pool.append({"provider": provider, "api_key": api_key})# 4. Execute Random Selection and Register with OpenClawif key_pool:print(f"🎲 Successfully read pool! Total keys ready to shuffle: {len(key_pool)}")selected = random.choice(key_pool)print(f"🌟 Randomly Activated Expert Provider: [{selected['provider']}]")# Feed directly to OpenClawlogin_cmd = f"openclaw models auth login --provider {selected['provider']} --key \"{selected['api_key']}\""subprocess.run(login_cmd, shell=True, check=True)# Route model endpoint selection parametersif "openrouter" in selected['provider'].lower():subprocess.run("openclaw models set openrouter/meta-llama/llama-3.1-405b-instruct:free", shell=True)elif "google" in selected['provider'].lower():subprocess.run("openclaw models set google/gemini-2.5-flash:free", shell=True)else:subprocess.run(f"openclaw models set {selected['provider']}/default", shell=True)print("\n✅ Setup completely synchronized and calibrated!")else:print("⚠ Extraction completed, but no usable rows containing credentials were found.")print("💡 Open your local '%USERPROFILE%\\my_free_keys.csv' and verify you replaced placeholder text with actual keys.")print("🔄 Bouncing core execution engine workspace...")subprocess.run("openclaw gateway restart", shell=True)except Exception as e:print(f"\n❌ Pipeline failed: {e}")
free_keys.csv+72