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

Function updateChannelCloseAIBalance

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

Source from the content-addressed store, hash-verified

154}
155
156func updateChannelCloseAIBalance(channel *model.Channel) (float64, error) {
157 url := fmt.Sprintf("%s/dashboard/billing/credit_grants", channel.GetBaseURL())
158 body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key))
159
160 if err != nil {
161 return 0, err
162 }
163 response := OpenAICreditGrants{}
164 err = json.Unmarshal(body, &response)
165 if err != nil {
166 return 0, err
167 }
168 channel.UpdateBalance(response.TotalAvailable)
169 return response.TotalAvailable, nil
170}
171
172func updateChannelOpenAISBBalance(channel *model.Channel) (float64, error) {
173 url := fmt.Sprintf("https://api.openai-sb.com/sb-api/user/status?api_key=%s", channel.Key)

Callers

nothing calls this directly

Calls 4

GetResponseBodyFunction · 0.85
GetAuthHeaderFunction · 0.85
GetBaseURLMethod · 0.80
UpdateBalanceMethod · 0.80

Tested by

no test coverage detected