Get Credits
Check your account balance and usage using .GetCredits().
Basic Usage
var credits = await Api.OpenAI
.GetCredits()
.ExecuteAsync();
Debug.Log($"Balance: ${credits.Balance}");
Debug.Log($"Used: ${credits.Used}");
Debug.Log($"Total: ${credits.Total}");Response Properties
public class CreditsResponse
{
public float Balance { get; set; } // Remaining balance
public float Used { get; set; } // Amount used
public float Total { get; set; } // Total allocated
}Unity Integration Examples
Example 1: Balance Monitor
Example 2: Usage Dashboard
Example 3: Pre-request Budget Check
Example 4: Periodic Balance Check
Provider Support
OpenAI
GroqCloud
Note: Not all providers support credit/billing queries. Check provider documentation.
Best Practices
✅ Good Practices
❌ Bad Practices
Error Handling
Next Steps
Tokenize - Get token IDs
Count Tokens - Count tokens for cost estimation
Last updated