## Get credit balance `client.AIGateway.Billing.CreditBalance(ctx, query) (*BillingCreditBalanceResponse, error)` **get** `/accounts/{account_id}/ai-gateway/billing/credit-balance` Retrieve the current credit balance, payment method info, and top-up configuration. ### Parameters - `query BillingCreditBalanceParams` - `AccountID param.Field[string]` Cloudflare account ID. ### Returns - `type BillingCreditBalanceResponse struct{…}` - `Balance float64` - `HasDefaultPaymentMethod bool` - `PaymentMethod BillingCreditBalanceResponsePaymentMethod` - `Brand string` - `Last4 string` - `TopupConfig BillingCreditBalanceResponseTopupConfig` - `Amount float64` - `DisabledReason string` - `Error string` - `LastFailedAt float64` - `Threshold float64` - `FirstTopupSuccess bool` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/ai_gateway" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.AIGateway.Billing.CreditBalance(context.TODO(), ai_gateway.BillingCreditBalanceParams{ AccountID: cloudflare.F("account_id"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Balance) } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "balance": 0, "has_default_payment_method": true, "payment_method": { "brand": "brand", "last4": "last4" }, "topup_config": { "amount": 0, "disabledReason": "disabledReason", "error": "error", "lastFailedAt": 0, "threshold": 0 }, "first_topup_success": true }, "success": true, "result_info": { "has_more": true, "page": 0, "per_page": 0, "total_count": 0 } } ```