valid.txt

xai-1VGGpgIiYFd9SsiVyQHeN6Qu6FUVldB2gUgfkOC9Godyxthn3QKfXZjLqJEqz7zYOuBSTT86DcSTjSX6
xai-pA94ra15S1Dzrnf0HvRkjHsZesZsAXqyJ8QmrG35bkdhCA1JcG3smqbqtTxGFMHMywO9shXkbpL0mdUb

keys.txt

1
2
3
4
5
6
7
8
xai-WGGqBP7EvG4v1x47p7kkTVlpga1q6fkm5t2JaCZPiR2lLhbuWFWPdC0uF9WiyR5OPgqzoWiYxSEBN6qR
xai-4slNih4UsLZbFmgGKa8sEAn3IEbH01tWdBotTPS1CCxDIryljhcnl6ak6Kn4ega4bgrLIzkotTapmloC
xai-uoMvikQBNFsDmXOqZh3MFfstiR8RXhTLDjdNaXrcUQUOkAyKfO0CfnPDklfnQh2VC2aGAl0ltJZd4Aio
xai-fNtR7p1fGxH5CD1j8XByXUwM1FedrlSpnQUzVYwifxVMqs6JIhWJeq2eAFlOSbhTVQNag5cqlAg3zNFn
xai-1VGGpgIiYFd9SsiVyQHeN6Qu6FUVldB2gUgfkOC9Godyxthn3QKfXZjLqJEqz7zYOuBSTT86DcSTjSX6
xai-DhVsbUZslGlzYHGwYISUcIPfHSs7yP4wYRJllW3FJlqA1YNUMCYHLkN12S1jHqZLJPkxfJEIb30nqCr5
xai-TJKZw6wP9GFhN6ahG05RVwx6cMpj9W2lFapQSQbQPmUCh7wCOij96R5EPULthS3u6y8Bvfky8HELUtLX
xai-pA94ra15S1Dzrnf0HvRkjHsZesZsAXqyJ8QmrG35bkdhCA1JcG3smqbqtTxGFMHMywO9shXkbpL0mdU

main.py

import requests
import re

# Configuration
GITHUB_TOKEN = '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'
HEADERS = {'Authorization': f'token {GITHUB_TOKEN}'}
REGEX_PATTERN = re.compile(r'xai-[a-zA-Z0-9]{80}')
OUTPUT_FILE = 'keys.txt'
PAGES_TO_SCRAPE = 5
RESULTS_PER_PAGE = 100


def get_raw_content_url(html_url):
    """Convert GitHub HTML URL to raw content URL."""
    return html_url.replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/')


def fetch_keys():
    keys = set()
    for page in range(1, PAGES_TO_SCRAPE + 1):
        # Search code for "xai-" on GitHub
        search_url = f'https://api.github.com/search/code?q="xai-"&per_page={RESULTS_PER_PAGE}&page={page}'
        response = requests.get(search_url, headers=HEADERS)

        if response.status_code != 200:
            print(f"Failed to fetch page {page}: Status {response.status_code}")
            break

        data = response.json()
        for item in data.get('items', []):
            try:
                # Fetch raw content
                raw_url = get_raw_content_url(item['html_url'])
                content_response = requests.get(raw_url)
                if content_response.status_code == 200:
                    matches = REGEX_PATTERN.findall(content_response.text)
                    for key in matches:
                        keys.add(key)
            except Exception as e:
                print(f"Error processing {item['html_url']}: {e}")
    return keys


if __name__ == "__main__":
    unique_keys = fetch_keys()
    with open(OUTPUT_FILE, 'w') as f:
        for key in unique_keys:
            f.write(f"{key}\n")
    print(f"Found {len(unique_keys)} keys and saved to {OUTPUT_FILE}")

checker.py

import os
from openai import OpenAI, APIError, AuthenticationError
import time


def validate_key(api_key):
    try:
        client = OpenAI(
            api_key=api_key,
            base_url="https://api.x.ai/v1",
        )

        # Simple validation request
        response = client.chat.completions.create(
            model="grok-2-latest",
            messages=[
                {"role": "system", "content": "You are a PhD-level mathematician."},
                {"role": "user", "content": "What is 2 + 2?"},
            ],
            timeout=10
        )

        # Basic content validation
        if "4" in response.choices[0].message.content:
            return True
        return False

    except AuthenticationError:
        return False
    except APIError as e:
        print(f"API Error: {e}")
        return False
    except Exception as e:
        print(f"Unexpected error: {e}")
        return False


def main():
    valid_count = 0

    with open("keys.txt", "r") as f:
        keys = [k.strip() for k in f.readlines() if k.strip()]

    with open("valid.txt", "w") as output:
        for idx, key in enumerate(keys, 1):
            print(f"Checking key {idx}/{len(keys)}...")

            if validate_key(key):
                output.write(f"{key}\n")
                valid_count += 1
                print(f"Valid key found! Total: {valid_count}")

            # Rate limiting prevention
            time.sleep(0.5)

    print(f"\nValidation complete! Found {valid_count} valid keys.")


if __name__ == "__main__":
    main()
Edit Report
Pub: 16 Feb 2025 23:30 UTC
Edit: 20 Feb 2025 08:05 UTC
Views: 386