Add /usage endpoint with token tracking, live balances, and cost calculations
This commit is contained in:
+12
@@ -235,6 +235,9 @@ sudo journalctl -u ein-ai-proxy -f --no-pager
|
||||
# Check proxy health
|
||||
curl https://ai.ein-softworks.com/health
|
||||
|
||||
# Check usage statistics
|
||||
curl https://ai.ein-softworks.com/usage
|
||||
|
||||
# Pull and deploy changes
|
||||
cd ~/ai-proxy && git pull
|
||||
sudo systemctl restart ein-ai-proxy
|
||||
@@ -268,6 +271,15 @@ GLM-4.7's thinking block signatures are different from Anthropic's and will be r
|
||||
### Zero Dependencies
|
||||
The proxy has zero npm dependencies — it uses only Node.js built-ins (`node:http`, `node:fs`, etc.). Do not add dependencies unless absolutely necessary.
|
||||
|
||||
### Usage Tracking
|
||||
The proxy automatically tracks token usage for all requests:
|
||||
- Token counts are extracted from both streaming and non-streaming responses
|
||||
- Data is persisted to `usage-data.json` (gitignored)
|
||||
- Monthly totals reset on the 1st of each month
|
||||
- Costs are calculated based on pricing in `config.json`
|
||||
- Live account balances are fetched from providers that support it (DeepSeek)
|
||||
- Use `curl https://ai.ein-softworks.com/usage` to view all usage data
|
||||
|
||||
## Key Reference URLs
|
||||
- **Proxy API**: https://ai.ein-softworks.com
|
||||
- **Gitea**: https://git.ein-softworks.com
|
||||
|
||||
Reference in New Issue
Block a user