How-To: View Credit Balance and Add Credit to Your Account
Accessing the Credit Balance
Last updated
Last updated
import lattica_common.auth_local_state as auth
import lattica_common.app_api as agent_app
# Notice your account token expires every 30 days and it's up to you to renew it
auth.set_session_token("your_account_token_you_got_in_your_email")
credits = agent_app.account.get_credits_balance()
if credits < 100:
try:
# Add credits to the account
agent_app.account.add_credits(200)
print(f"Added {CREDITS_TO_ADD} credits to your account successfully.")
except Exception as e:
# Handle any errors that occur during the credit addition
print(f"Failed to add credits: {e}")
else:
print("Sufficient credits available. No need to add more credits.")