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

Function updateChannelAPI2GPTBalance

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

Source from the content-addressed store, hash-verified

212}
213
214func updateChannelAPI2GPTBalance(channel *model.Channel) (float64, error) {
215 url := "https://api.api2gpt.com/dashboard/billing/credit_grants"
216 body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
217
218 if err != nil {
219 return 0, err
220 }
221 response := API2GPTUsageResponse{}
222 err = json.Unmarshal(body, &response)
223 if err != nil {
224 return 0, err
225 }
226 channel.UpdateBalance(response.TotalRemaining)
227 return response.TotalRemaining, nil
228}
229
230func updateChannelSiliconFlowBalance(channel *model.Channel) (float64, error) {
231 url := "https://api.siliconflow.cn/v1/user/info"

Callers 1

updateChannelBalanceFunction · 0.85

Calls 3

GetResponseBodyFunction · 0.85
GetAuthHeaderFunction · 0.85
UpdateBalanceMethod · 0.80

Tested by

no test coverage detected