Skip to main content
GET
/
v1
/
tasks
/
{task_id}
/
llm_usage
Get Task Llm Usage
curl --request GET \
  --url https://api.xpander.ai/v1/tasks/{task_id}/llm_usage \
  --header 'x-api-key: <api-key>'
{
  "task_id": "<string>",
  "tokens": 0,
  "input_tokens": 0,
  "output_tokens": 0,
  "actions": 0,
  "is_byok": false,
  "cost": 0
}

Documentation Index

Fetch the complete documentation index at: https://docs.xpander.ai/llms.txt

Use this file to discover all available pages before exploring further.

Retrieve LLM token usage statistics for a specific task, including input/output token counts and the number of tool actions performed.

Path Parameters

task_id
string
required
Unique identifier of the task (UUID format)

Response

task_id
string
Unique identifier of the task
tokens
integer
Total number of LLM tokens consumed (input + output)
input_tokens
integer
Number of input (prompt) tokens consumed
output_tokens
integer
Number of output (completion) tokens generated
actions
integer
Number of tool actions performed during the task
is_byok
boolean
Whether the task used a Bring Your Own Key (BYOK) model configuration
cost
number
Estimated USD cost for non-BYOK executions in this task, rounded to 5 decimal places. 0.0 means no billable usage (empty task or fully BYOK).

Example Request

curl -X GET -H "x-api-key: <your-api-key>" \
  "https://api.xpander.ai/v1/tasks/<task-id>/llm_usage"

Example Response

{
  "task_id": "e6cf93db-30c7-471b-a1a9-5051a2c9e4ba",
  "tokens": 3842,
  "input_tokens": 1520,
  "output_tokens": 2322,
  "actions": 4,
  "is_byok": false,
  "cost": 0.01284
}

Use Cases

  • Track token consumption - Monitor LLM token usage for individual tasks
  • Cost tracking - cost is returned directly in USD, rounded to 5 decimal places (excludes BYOK executions)
  • Usage auditing - Review resource consumption across tasks
  • BYOK tracking - Identify which tasks ran with your own API keys vs. platform-provided keys

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

task_id
string
required

Response

Successful Response

LLM usage summary for a single task, including aggregated tokens, tool actions, BYOK indicator, and estimated USD cost (excludes BYOK executions).

task_id
string
required
tokens
integer | null
default:0

Total LLM tokens consumed (input + output).

input_tokens
integer | null
default:0

Number of input (prompt) tokens consumed.

output_tokens
integer | null
default:0

Number of output (completion) tokens generated.

actions
integer | null
default:0

Number of tool actions performed during the task.

is_byok
boolean
default:false

True if any execution in this task used BYOK (customer-provided LLM credentials). When True, cost reflects only the non-BYOK executions; BYOK executions are billed by the customer's own provider and are excluded from the figure.

cost
number<float>
default:0

Estimated USD cost for non-BYOK executions in this task, rounded to 5 decimal places. 0.0 means no billable usage (empty task or fully BYOK).