MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / updateChannelSiliconFlowBalance

Function updateChannelSiliconFlowBalance

controller/channel-billing.go:230–250  ·  view source on GitHub ↗
(channel *model.Channel)

Source from the content-addressed store, hash-verified

228}
229
230func updateChannelSiliconFlowBalance(channel *model.Channel) (float64, error) {
231 url := "https://api.siliconflow.cn/v1/user/info"
232 body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
233 if err != nil {
234 return 0, err
235 }
236 response := SiliconFlowUsageResponse{}
237 err = json.Unmarshal(body, &response)
238 if err != nil {
239 return 0, err
240 }
241 if response.Code != 20000 {
242 return 0, fmt.Errorf("code: %d, message: %s", response.Code, response.Message)
243 }
244 balance, err := strconv.ParseFloat(response.Data.TotalBalance, 64)
245 if err != nil {
246 return 0, err
247 }
248 channel.UpdateBalance(balance)
249 return balance, nil
250}
251
252func updateChannelDeepSeekBalance(channel *model.Channel) (float64, error) {
253 url := "https://api.deepseek.com/user/balance"

Callers 1

updateChannelBalanceFunction · 0.85

Calls 3

GetResponseBodyFunction · 0.85
GetAuthHeaderFunction · 0.85
UpdateBalanceMethod · 0.80

Tested by

no test coverage detected