How to track a run's cost in USD?

I'm using the Python SDK to run apify actors and get data for my application> I want to track how much money I'm spending on each run so I can calculate my average costs. As I spoke with the Apify AI chat bot and by reading the documentation, I discovered that there is the 'usageTotalUsd' key in the run object that should represent how much I paid for the run. However, the data isn't right at all. In the apify dashboard I'll see one number and in my logs I will see a different value for how much I actually paid.
# ...
run_input = {
# Run input data
}

# Running the scraper
run = apify_client.actor("apify/instagram-scraper").call(run_input=run_input)
for user in apify_client.dataset(run["defaultDatasetId"]).iterate_items():
# Process the result...

print('Run usage: ', run['usageTotalUsd'])
total_apify_usage += run['usageTotalUsd']

# ...
# ...
run_input = {
# Run input data
}

# Running the scraper
run = apify_client.actor("apify/instagram-scraper").call(run_input=run_input)
for user in apify_client.dataset(run["defaultDatasetId"]).iterate_items():
# Process the result...

print('Run usage: ', run['usageTotalUsd'])
total_apify_usage += run['usageTotalUsd']

# ...
Am I doing something wrong?
2 Replies
Hall
Hall3mo ago
Someone will reply to you shortly. In the meantime, this might help:
Pepa J
Pepa J3mo ago
Hi @Nel549 , Can you try to wait about 5secs after the Run, and then call Actor.get for the same Run and compare the price with the one on the Platform?

Did you find this page helpful?