AgentBill icon

AgentBill

Interact with AgentBill API for AI usage tracking & billing

Actions16

Overview

This node interacts with the AgentBill API to track AI usage and costs. Specifically, the 'Track AI Usage' operation under the 'Cost Guard' resource records actual AI usage data after a request completes. It is useful for monitoring and billing AI model usage by capturing details such as customer ID, model, provider, token usage, latency, cost, and agent ID. Practical applications include integrating AI usage tracking into workflows to maintain accurate billing and usage analytics.

Use Case Examples

  1. Recording AI usage data after a chat completion to track tokens used and cost incurred.
  2. Logging AI model usage with provider details and latency for performance monitoring.

Properties

Name Meaning
Customer ID Your customer identifier (max 255 characters) used to associate usage with a specific customer.
Model AI model name used for the request (e.g., gpt-4o-mini, claude-sonnet-4-5).
Provider AI provider for the model (e.g., OpenAI, Anthropic, Google AI, AWS Bedrock, Azure OpenAI, Mistral).
Input Tokens Actual input tokens used in the AI request.
Output Tokens Actual output tokens generated by the AI request.
Latency (ms) Request latency in milliseconds, indicating the time taken for the AI request.
Cost Calculated cost in USD for the AI usage recorded.
Agent ID Agent UUID to identify the agent making the request, obtained from the AgentBill dashboard.
Event Name Custom event name to categorize the AI usage event (e.g., ai_request, code_generation, chat_response).

Output

JSON

  • api_key - API key used for authentication with AgentBill API.
  • customer_id - Customer identifier associated with the usage.
  • agent_id - Agent UUID associated with the usage event.
  • event_name - Custom event name for the usage event.
  • model - AI model name used in the request.
  • provider - AI provider name.
  • prompt_tokens - Number of input tokens used.
  • completion_tokens - Number of output tokens generated.
  • latency_ms - Latency of the request in milliseconds.
  • cost - Cost in USD for the AI usage.

Dependencies

  • AgentBill API

Troubleshooting

  • Ensure the Customer ID is provided and does not exceed 255 characters; otherwise, the node throws an error.
  • Agent ID is required for tracking usage; missing this will cause an error.
  • Input tokens and output tokens must be non-negative numbers within allowed ranges.
  • The 'messages' parameter for validation must be a valid JSON array; invalid JSON will cause an error.
  • API key credential must be correctly configured to authenticate requests to AgentBill API.

Links

Discussion