agentpit-tokens

Create a Prisma model and API route for reporting token usage.

Updated Feb 20, 2026
One-click install
npx skills add https://github.com/hangeaiagent/agentpit-Skills --skill agentpit-tokens
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: agentpit-tokens
Source: https://github.com/hangeaiagent/agentpit-Skills/tree/main/skills/agentpit-tokens
Command: npx skills add https://github.com/hangeaiagent/agentpit-Skills --skill agentpit-tokens

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Token usage reporting within AgentPit projects enables external agents to report consumption metrics, enabling auditing, billing, and usage tracking across the platform.

Core Features & Use Cases

  • Prisma model extension: adds TokenUsage with fields for agentId, applicationId, userId, tokensUsed, startedAt, endedAt, and optional modelName, requestId, metadata.
  • API route: POST /api/v1/tokens/report with ApiKey authentication to submit reports and persist them.
  • Use Case: An external Agent application reports per-request token usage to tie activity to an Agent and Application for cost accounting and analytics.

Quick Start

Add this skill to your AgentPit project and run through the prompts to generate the Prisma model and API route.

Frequently Asked Questions about agentpit-tokens

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I track token usage for external agents in a Next.js application?

Token usage reporting enables external agents to submit consumption metrics via an API route, persisting data like agentId, applicationId, and tokensUsed in a Prisma model for auditing and billing.

What is the best way to validate API token consumption reports from external integrations?

Validating API token consumption reports involves using an API route that requires ApiKey authentication to securely accept and validate token usage data submitted by external agents.

Does this token usage API approach require Prisma and Next.js?

Yes, implementing this token usage API requires Prisma for model scaffolding and Next.js for the API route that authenticates and persists the token consumption data.

What data fields are needed for a Prisma model to log token usage?

A Prisma model for token usage requires fields including agentId, applicationId, userId, tokensUsed, startedAt, and endedAt, with optional modelName, requestId, and metadata fields.

How do I secure an API endpoint for reporting agent token consumption?

Securing an API endpoint for reporting token consumption involves implementing ApiKey authentication to validate external agent requests before persisting the usage data to the database.