Tasks
Browse available tasks and calculate their credit cost, exposed through client.tasks. A "task" represents a billable unit of work on the chat, stt, tts, or ocr platforms.
List tasks
tasks = client.tasks.list(
search=None, # search by name
per_page=10,
page=1,
sort=None, # name, -name, order_column, -order_column, slug, -slug
platform=None, # chat, stt, tts, ocr
extra_params=None, # dict of additional query parameters
timeout=None, # override the client's default timeout, in seconds
)
Get a task
task = client.tasks.get("audio_generation")
{
"data": {
"name": "ލިޔުމުން ކިޔުން",
"description": None,
"slug": "audio_generation",
"order_column": 7,
"platform": "tts",
"unit_charged": "character",
"rate": 0.01,
}
}
Calculate task cost
Calculates the credits that would be charged for a number of usage units, using a task's current rate and charging unit.
cost = client.tasks.calculate(
task="audio_generation",
units=1000,
extra_params=None, # dict of additional body parameters
timeout=None, # override the client's default timeout, in seconds
)
{
"task": {"slug": "audio_generation", "unit_charged": "character", "rate": 0.01, ...},
"units": 1000,
"units_used": 1000,
"units_charged": 1000,
"charged_credits": 10,
"credits_available": 5533.45,
"can_proceed": True,
}
Raises dhivehigpt_sdk.ValidationError when task does not identify an available task.