| name | deepseek-usage |
| description | Query DeepSeek API usage (balance, monthly spending, per-model token details, daily breakdown, cache hit rate). Access DeepSeek Open Platform via browser_use, auto-login and export monthly data. Requires user to configure DeepSeek account credentials in local environment variables. Triggered when user says "check usage", "check token consumption", "check spending", "check balance", "how much used today".
|
| version | 1.1.0 |
| compatibility | Requires python3. DEEPSEEK_EMAIL and DEEPSEEK_PASSWORD env vars. |
DeepSeek API Usage Query
⚠️ Security Notice
This skill requires DeepSeek login credentials to work.
Credentials are stored only in local environment variables. Minis will not upload them to any server.
If you don't trust this approach, delete this skill or do not set credentials.
Prerequisites (first time only, one-time setup)
1. Set Environment Variables
Add the following two variables in Minis Settings → Environment Variables:
| Variable | Description | Example Value |
|---|
DEEPSEEK_EMAIL | Your DeepSeek platform login email | user@example.com |
DEEPSEEK_PASSWORD | Your DeepSeek platform login password | your_password_here |
🔗 Open environment variables settings
If your account uses Google/WeChat or other third-party login, this skill cannot be used.
2. Verify Configuration
[ -n "$DEEPSEEK_EMAIL" ] && [ -n "$DEEPSEEK_PASSWORD" ] && echo "Configured" || echo "Not configured"
Query Flow (only 2 tool calls)
Step 1: Navigate and ensure login (1 tool call)
actions:
- set_user_agent: desktop_chrome
- navigate: https://platform.deepseek.com/usage
- If not logged in, fill DEEPSEEK_EMAIL / DEEPSEEK_PASSWORD from environment variables and submit login
- wait_for_dom_stable
Step 2: Execute complete JS script in one shot (1 execute_js)
The following JS script handles the complete logic: get Token → download zip → unzip → parse CSV → output.
Execute the entire JS script at once via execute_js --script.
(async () => {
const token = JSON.parse(localStorage.getItem('userToken')).value;
if (!token) return JSON.stringify({ error: 'no_token' });
const resp = await fetch('https://platform.deepseek.com/api/v0/usage/export?month=5&year=2026', {
headers: { 'Authorization': 'Bearer ' + token }
});
const blob = await resp.blob();
const script = document.createElement('script');
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js';
await new Promise(r => { script.onload = r; document.head.appendChild(script); });
const zip = await JSZip.loadAsync(blob);
const costText = await zip.file('cost-2026-5.csv').async('text');
const amountText = await zip.file('amount-2026-5.csv').async('text');
const costLines = costText.trim().split('\n').slice(1);
const modelCost = {};
let totalCost = 0;
for (const line of costLines) {
const p = line.split(',');
const model = p[2], cost = parseFloat(p[4]) || 0;
modelCost[model] = (modelCost[model] || 0) + cost;
totalCost += cost;
}
const allLines = amountText.trim().split('\n').slice(1);
const filteredLines = allLines;
const models = {};
for (const line of filteredLines) {
const p = line.split(',');
const model = p[2], type = p[5], amount = parseInt(p[7]) || 0;
if (!models[model]) models[model] = { requests: 0, cache_hit: 0, cache_miss: 0, output: 0 };
if (type === 'request_count') models[model].requests += amount;
else if (type === 'input_cache_hit_tokens') models[model].cache_hit += amount;
else if (type === 'input_cache_miss_tokens') models[model].cache_miss += amount;
else if (type === 'output_tokens') models[model].output += amount;
}
let result = '';
let gr = 0, go = 0, gh = 0, gm = 0;
for (const [m, d] of Object.entries(models)) {
const ti = d.cache_hit + d.cache_miss;
const hr = ti > 0 ? (d.cache_hit / ti * 100).toFixed(1) : '0.0';
const co = modelCost[m] || 0;
result += `${m}|${d.requests}|${d.output}|${d.cache_hit}|${d.cache_miss}|${ti}|${hr}|${co.toFixed(2)}\n`;
gr += d.requests; go += d.output; gh += d.cache_hit; gm += d.cache_miss;
}
const ti = gh + gm;
const hr = ti > 0 ? (gh / ti * 100).toFixed(1) : '0.0';
result += `TOTAL|${gr}|${go}|${gh}|${gm}|${ti}|${hr}|${totalCost.toFixed(2)}`;
return result;
})();
⚠️ Note: execute_js returns text wrapped in JSON. The AI needs to parse data.text to get the actual result.
Step 3: Screenshot (1 tool call, optional)
screenshot: current page
Step 4: Report (memory_write decided by user)
Whether to write results to daily log is decided by user. Only write when explicitly requested.
Output Format
Balance: ¥X.XX | Monthly spent: ¥X.XX
| Model | Requests | Output Tokens | Cache Hit | Cache Miss | Total Input Tokens | Cache Hit Rate | Cost |
|---|
| deepseek-v4-pro | X | X | X | X | X | X% | ¥X.XX |
| deepseek-v4-flash | X | X | X | X | X | X% | ¥X.XX |
| Total | X | X | X | X | X | X% | ¥X.XX |
⚠️ Security Notes (Must Follow)
API Key Leak Risk
Column 5 (index 4) of amount CSV is the api_key field, containing the user's DeepSeek API Key in plaintext.
Must follow:
- When parsing CSV, reference by column index (e.g.
p[2], p[5], p[7]), do not reference the whole row
- Prohibited from exposing api_key content in any replies, logs or screenshots
- If you need to view CSV content during debugging, only print the header (row 1), not the data rows
Credential Security
- Email and password stored in Minis local environment variables, not uploaded
- localStorage Token is only valid for the current browser session
- It is recommended to change passwords regularly
Pitfall Log
| Problem | Cause | Solution |
|---|
| Export button click not working | Export button is <div> not <button> | Use querySelector to match text "Export" then .click() |
| browser_use fetch returns Missing Token | fetch does not carry page cookies | Use execute_js to execute fetch in page context instead |
| JSZip load failed | import() method not supported | Use document.createElement('script') to dynamically load CDN |
| CSV parses 0 records | Wrong field index guessed | Verify headers first (amount 8 cols, cost 6 cols), then reference by index |
| amount.csv contains API Key plaintext | Column 5 is api_key | Reference by column name when parsing, don't print full row |
| minis-browser-use CLI state lost across calls | Each call is an independent process | Put all JS logic in one execute_js, don't pass state across navigate/execute_js |