Log in to the web console to access the Main Page, which provides an overview of your account’s balance and usage.
Monitoring Credit Balance and Usage
The dashboard displays the following key metrics:
1
Credit Balance
Available Credits: Shows the current amount of credits remaining in your account.
Approximate Remaining Usage Time: Provides an estimate of how long workers can run on the remaining credits, calculated as the total runtime across all workers in your account.
The approximate time represents the total runtime for all workers. For example, if the remaining usage time is estimated at 4 days and you run 4 workers in parallel, your credits will last for 1 day of operation for all 4 workers.
This calculation is approximate because the platform may support different types of workers in the future, each with varying usage rates. Currently, the estimate is based on the default worker type.
2
Worker Runtime Summary
Total Worker Runtime: Displays the total runtime of all workers associated with your account.
Per-Model Breakdown: This shows runtime usage for each AI model, helping you identify which models consume the most resources.
3
End-User Query Summary
Total Queries: This shows the total number of end-user queries processed across all models.
Per-Model Breakdown: Displays query statistics for each AI model, helping you understand which models are queried most frequently.
Custom Periods for Worker Runtime and Queries
Both Worker Runtime Summary and End-User Query Summary can be viewed for the following periods:
Daily: Statistics for the last 24 hours.
Monthly: Statistics for the last calendar month.
Yearly: Statistics for the last calendar year.
from datetime import datetime
import lattica_common.auth_local_state as auth
import lattica_common.app_api as agent_app
# Function to convert a datetime object to Unix timestamp in milliseconds
def to_unix_millis(dt: datetime) -> int:
return int(dt.timestamp() * 1000)
# 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()
# Example Date Range 1: January 1, 2024 to January 31, 2024
start_date1 = to_unix_millis(datetime(2024, 1, 1))
end_date1 = to_unix_millis(datetime(2024, 1, 31, 23, 59, 59))
# In the given dates range, returns a list of worker sessions runtime per model
# of the account.
account_worker_sessions = agent_app.account.get_worker_sessions(start_date1, end_date1)
# Example Date Range 2: February 1, 2024 to February 28, 2024
start_date2 = to_unix_millis(datetime(2024, 2, 1))
end_date2 = to_unix_millis(datetime(2024, 2, 28, 23, 59, 59))
# In the given dates range, returns a list of queries done per model of the account
account_models_usage = agent_app.account.get_queries_per_model(start_date2, end_date2)