Introduction¶
When calling the DeepSeek API within DSH, you often need to check a few types of information: remaining account balance, actual consumption today, token composition, and whether the cost trend for the past week or this month is abnormal. Viewing these information by switching to external platform pages interrupts the current workflow.
dsh-codex-meter integrates these usage metrics into the DSH Settings → Usage page: balance, today’s consumption, token analysis, cost trends, and real-time API activity can all be viewed on the local page. It is integrated as a DSH plugin, not a standalone site or an official app store entry.
About¶
dsh-codex-meter is a DSH plugin maintained by ChrisZhangWG and licensed under MIT. It targets the DSH web client, is designed as a DSH standard bundle plugin, and uses dsh.bundle.patch and dsh.client for integration.
It primarily solves the following problems:
- View DeepSeek API balance within DSH;
- View today’s consumption and token composition within DSH;
- View
7D/Monthcost trends within DSH; - View if current API calls are in
Active/Idlestate within DSH.
The plugin interface is entirely in English.
Core Features¶
Settings → Usage Page¶
dsh-codex-meter provides a native Settings → Usage page displaying data related to DeepSeek API usage.
The page displays the following data items:
Account balance: DeepSeek API balance;Today: Today’s consumption;Last balance change: The last balance change.
If DEEPSEEK_PLATFORM_TOKEN is configured, Today related data can come from the official interface; if not configured or the token is invalid, the page falls back to local estimation.
Today’s Token Analysis¶
Today's token analysis displays today’s official analysis information, including:
- Number of requests;
- Today’s cost;
Cache efficiencyrange scale;Context sizerange scale.
It is used to assess today’s request volume, cache efficiency, and context usage.
Official Cost Trend¶
Official cost trend provides two views:
7D
Month
Each daily cost point displays a data label and stats for the period:
Total
Daily avg
Peak
This view is suitable for viewing weekly or monthly cost changes.
API Activity¶
API activity displays real-time status:
Active
Idle
Where:
Activeindicates that model API requests are currently running;Idleindicates that there are currently no model API requests.
Tool execution, permission waiting, etc. are not counted as active API calls.
API activity is not cached and always comes from the real-time activity interface:
GET /api/codex-meter/api-activity
Caching Behavior¶
The plugin’s usage cache has a lifetime of 7 days.
When opening Settings → Usage, the page first displays the most recent successfully fetched statistical data while continuing to fetch the latest data. During the refresh, it displays:
Showing saved data · refreshing…
If the refresh fails, the plugin retains existing data and does not clear the existing statistics directly.
Key Boundaries¶
The plugin only caches and displays statistical data, such as balance, today’s consumption, official token analysis, trend data, etc.
The plugin does not cache the following types of information:
DEEPSEEK_PLATFORM_TOKEN
API Key
Credentials
The browser only accesses the host’s local routes. No key values are stored in the repository, and keys are not sent to the browser.
Installation and Activation¶
General Installation¶
It is recommended to install to a specific profile using the DSH plugin command:
dsh plugin --profile <name> add dsh-codex-meter
To install from the GitHub repository, you can use:
dsh plugin --profile <name> add github:ChrisZhangWG/dsh-codex-meter
If the profile name is web, you can use:
dsh plugin --profile web add dsh-codex-meter
Desktop Manual Connection¶
When manual connection is needed for the desktop version, first copy the plugin package to the profile’s node_modules:
PROFILE=~/.dsh/profiles/desktop
mkdir -p "$PROFILE/node_modules"
cp -R dsh-codex-meter "$PROFILE/node_modules/"
Then symlink the host dependencies:
mkdir -p "$PROFILE/node_modules/@deepseek-ai"
ln -sfn "/Applications/DSH Desktop.app/Contents/Resources/app.asar.unpacked/node_modules/@deepseek-ai/dsh-credentials" \
"$PROFILE/node_modules/@deepseek-ai/dsh-credentials"
Append the loader entry in $PROFILE/cordis.patch.yml:
- insert:
- id: codex-meter
name: dsh-codex-meter
After fully restarting DSH Desktop, go to:
Settings → Usage
to view the plugin page.
The host dependency version constraints are:
@deepseek-ai/dsh-credentials >=0.1.0-rc.6 <0.2.0-0
Typical Usage¶
Reading Balance¶
Balance reading uses:
DEEPSEEK_API_KEY
After configuration, Account balance in Settings → Usage can display the DeepSeek API balance.
Obtaining Official Data¶
Official data requires:
DEEPSEEK_PLATFORM_TOKEN
The method is as follows:
- Login to
platform.deepseek.com; - Open the browser DevTools Console;
- Execute the following expression:
JSON.parse(localStorage.getItem('userToken')).value
Save the obtained token to:
~/.dsh/.credentials.yaml
Example:
DEEPSEEK_PLATFORM_TOKEN: <token>
After configuration, today’s official consumption, trend chart, and daily related data come from the official interface.
Note that DEEPSEEK_PLATFORM_TOKEN expires with the platform session. When invalid, the Today row will display:
Today (refresh needed)
and automatically falls back to local estimation. After re-obtaining the token, official data can be restored.
Local Testing¶
If you need to run tests:
npm test
Host Routes¶
The plugin uses the following host routes:
GET /api/codex-meter/balance
GET /api/codex-meter/api-activity
GET /api/codex-meter/session-cost
Where:
GET /api/codex-meter/balanceis used for balance, official data, today’s analysis, balance changes, etc.;GET /api/codex-meter/api-activityis used for real-timeActive/Idlestatus;GET /api/codex-meter/session-costis local estimation, not the official account deduction record; theSettings → Usagepage does not use it.
Use Cases and Notes¶
dsh-codex-meter is suitable for the following scenarios:
- Want to view DeepSeek API balance within DSH;
- Want to put today’s consumption, token composition, and cost trend into
Settings → Usage; - Want to distinguish
Active/Idleto determine if there are current model API requests; - Want to reduce switching back and forth between DSH and platform pages.
Pre-use notes:
- The plugin runs as a DSH plugin, using the current DSH process permissions and local credentials;
- Source code, dependencies, and license should be checked before installation;
- Official data depends on
DEEPSEEK_PLATFORM_TOKEN, which may expire with the platform session; API activityonly indicates the status of model API calls; tool execution and permission waiting are not counted as active calls;- Local estimation data is not an official account deduction record.
Regarding the license, dsh-codex-meter is MIT. The price engine is ported from bpc-oss/dsh-web-billing, and the host logic references dsh-deepseek-quota; both are MIT.
Conclusion¶
The value of dsh-codex-meter lies in: aggregating DeepSeek API balance, today’s consumption, token composition, cost trends, and real-time API activity into DSH’s Settings → Usage page. It does not change DeepSeek platform billing rules, nor does it expose keys to the browser; it provides a usage view that is locally verifiable, cacheable for display, and retains real-time API status.
GitHub Repository:
https://github.com/ChrisZhangWG/dsh-codex-meter
The DSH Community Directory is a standalone site and has no official affiliation with DeepSeek / HF. The materials verified this time do not provide the directory page URL for this plugin, so the specific directory link is not written; if needed, search for the plugin name dsh-codex-meter in the DSH Community Directory.