Files

29 lines
912 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""DeepSeek 开放平台余额。
接口:GET https://api.deepseek.com/user/balance
响应:{"is_available": true, "balance_infos": [{"currency": "CNY", "total_balance": "1.34", ...}]}
"""
from __future__ import annotations
from app.expr import evaluate_balance
from app.providers.base import BalanceProvider
class DeepSeekProvider(BalanceProvider):
id = "deepseek"
name = "DeepSeek"
currency = "CNY"
icon = "DeepSeek"
description = "DeepSeek 开放平台余额(GET /user/balanceBearer 认证)"
def build_request(self, api_key: str) -> tuple[str, dict, str | None]:
return (
"https://api.deepseek.com/user/balance",
{"Accept": "application/json", "Authorization": f"Bearer {api_key}"},
None,
)
def extract_balance(self, data: object) -> float:
return evaluate_balance(data, "balance_infos[0].total_balance")