29 lines
912 B
Python
29 lines
912 B
Python
"""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/balance,Bearer 认证)"
|
||
|
||
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")
|