添加余额查询方法

This commit is contained in:
MartialBE
2023-12-02 17:51:28 +08:00
parent d8b13b2c07
commit 5e08cc8719
8 changed files with 116 additions and 5 deletions

View File

@@ -2,18 +2,16 @@ package closeai
import (
"errors"
"fmt"
"one-api/common"
"one-api/model"
)
func (p *CloseaiProxyProvider) Balance(channel *model.Channel) (float64, error) {
fullRequestURL := p.GetFullRequestURL("/sb-api/user/status", "")
fullRequestURL = fmt.Sprintf("%s?api_key=%s", fullRequestURL, channel.Key)
fullRequestURL := p.GetFullRequestURL("/dashboard/billing/credit_grants", "")
headers := p.GetRequestHeaders()
client := common.NewClient()
req, err := client.NewRequest("GET", fullRequestURL, common.WithBody(nil), common.WithHeader(headers))
req, err := client.NewRequest("GET", fullRequestURL, common.WithHeader(headers))
if err != nil {
return 0, err
}