硅基流动Token有效性批量检测

Jesn · 2024-11-1 13:42:32 · 28 次点击

搞了个硅基流动Token有效性批量检测的页面,方便一件筛选有效的token


<!DOCTYPE html>
<html lang="zh-CN">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>批量检测账号有效性</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 20px;
background-color: #f0f2f5;
color: #333;
}

.container {
max-width: 800px;
margin: 0 auto;
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
}

textarea {
width: 98%;
height: 200px;
margin-bottom: 20px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
resize: vertical;
}

button {
display: block;
width: 100%;
padding: 12px;
background-color: #3498db;
color: #fff;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}

button:hover {
background-color: #2980b9;
}

button:disabled {
background-color: #95a5a6;
cursor: not-allowed;
}

.results {
margin-top: 30px;
}

.results h2 {
color: #2c3e50;
margin-bottom: 10px;
}

.results-content {
background-color: #f9f9f9;
padding: 15px;
border-radius: 4px;
border: 1px solid #ddd;
font-size: 14px;
max-height: 300px;
overflow-y: auto;
}

#validResults {
border-left: 4px solid #2ecc71;
white-space: pre-wrap;
}

#invalidResults {
border-left: 4px solid #e74c3c;
}

.invalid-token {
background-color: #ffecec;
padding: 12px;
margin-bottom: 12px;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.invalid-token-content {
display: flex;
flex-direction: column;
}

.invalid-token-token {
font-family: monospace;
background-color: #fff;
padding: 6px;
border-radius: 3px;
margin-bottom: 6px;
border: 1px solid #ffcccb;
word-break: break-all;
}

.invalid-token-message {
color: #c0392b;
font-weight: bold;
}

.loader {
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 1s linear infinite;
display: inline-block;
vertical-align: middle;
margin-right: 10px;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

.copy-button {
background-color: #27ae60;
margin-top: 10px;
}

.copy-button:hover {
background-color: #2ecc71;
}
</style>
</head>

<body>
<div class="container">
<h1>硅基流动Token有效性检测</h1>
<textarea id="tokens" placeholder="请在此输入sk token,每行一个"></textarea>
<button id="checkButton" onclick="checkTokens()">检测账号</button>
<div class="results">
<h2>有效账号</h2>
<div id="validResults" class="results-content"></div>
<button id="copyButton" class="copy-button" onclick="copyValidTokens()"
style="display: none;">复制所有有效账号</button>
<h2>无效账号</h2>
<div id="invalidResults" class="results-content"></div>
</div>
</div>

<script>
async function checkTokens() {
const tokensTextarea = document.getElementById('tokens');
const checkButton = document.getElementById('checkButton');
const validResults = document.getElementById('validResults');
const invalidResults = document.getElementById('invalidResults');
const copyButton = document.getElementById('copyButton');

const tokens = tokensTextarea.value.split('\n').filter(token => token.trim() !== '');

if (tokens.length === 0) {
alert('请输入至少一个token');
return;
}

checkButton.disabled = true;
checkButton.innerHTML = '<span class="loader"></span>检测中...';
validResults.textContent = '';
invalidResults.innerHTML = '';
copyButton.style.display = 'none';

const results = await Promise.all(tokens.map(checkToken));

const validTokens = results.filter(r => r.isValid).map(r => r.token);
const invalidTokens = results.filter(r => !r.isValid);

validResults.textContent = validTokens.join('\n');

invalidTokens.forEach(result => {
const div = document.createElement('div');
div.className = 'invalid-token';
div.innerHTML = `
<div class="invalid-token-content">
<div class="invalid-token-token">${result.token}</div>
<div class="invalid-token-message">${result.message}</div>
</div>
`;
invalidResults.appendChild(div);
});

if (validTokens.length > 0) {
copyButton.style.display = 'block';
}

checkButton.disabled = false;
checkButton.textContent = '检测账号';
}

async function checkToken(token) {
try {
const response = await fetch('https://api.siliconflow.cn/v1/chat/completions', {
method: 'POST',
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) CherryStudio/0.8.7 Chrome/120.0.6099.291 Electron/28.3.3 Safari/537.36',
'Accept': 'application/json',
'Content-Type': 'application/json',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120"',
'x-stainless-os': 'Unknown',
'x-stainless-lang': 'js',
'sec-ch-ua-mobile': '?0',
'authorization': `Bearer ${token}`,
'x-stainless-package-version': '4.59.0',
'x-stainless-runtime': 'browser:chrome',
'x-stainless-arch': 'unknown',
'x-stainless-runtime-version': '120.0.6099',
'x-api-key': token,
'sec-ch-ua-platform': 'macOS',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Accept-Language': 'zh-CN'
},
body: JSON.stringify({
"model": "Qwen/Qwen2.5-72B-Instruct",
"messages": [
{
"role": "user",
"content": "hi"
}
],
"max_tokens": 100,
"stream": false
})
});

if (response.ok) {
return { token, isValid: true };
} else {
const errorData = await response.json();
return { token, isValid: false, message: errorData.message };
}
} catch (error) {
return { token, isValid: false, message: `请求失败: ${error.message}` };
}
}

function copyValidTokens() {
const validResults = document.getElementById('validResults');
const textArea = document.createElement('textarea');
textArea.value = validResults.textContent;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
alert('有效账号已复制到剪贴板');
}
</script>
</body>

</html>
举报· 28 次点击
登录 注册 站外分享
1 条回复  
The.one 初学 2024-11-1 13:47:43

还可以加上 api 剩余额度请求

返回顶部