{
 "schema": "aiblocks-page/1",
 "id": "your-agent-s-first-ai-call-implementation-planner",
 "type": "skill",
 "name": "Agent AI cost tracker builder",
 "summary": "Plan a wrapper for your agent's AI calls that checks the budget first, then records tokens and cost on every call, so spend is never a surprise.",
 "headline": "Agent AI cost tracker builder",
 "subhead": "Give it the AI models you plan to use, the job labels each call may carry, a typical call size and your budget. It plans one wrapper that every agent calls. You get the wrapper changes, a cost record and test cases, not a live system.",
 "job": {
  "id": "build-software",
  "name": "Build and ship software"
 },
 "level": "intermediate",
 "thinking": "medium",
 "tested": true,
 "updated": "2026-10-28",
 "first_published": "2026-10-25",
 "inputs": [
  {
   "type": "codebase",
   "required": true,
   "label": "Codebase",
   "what": "a project's code, in a folder or repo the AI can open"
  }
 ],
 "outputs": [
  {
   "type": "code_change",
   "required": true,
   "label": "Code change",
   "what": "a change to the code, with what it fixes and how it was checked"
  }
 ],
 "you_give": [
  "The AI model or models you plan to use, and the provider",
  "The job labels each call may carry, such as chat or audit",
  "A typical call size, meaning input and output tokens (optional)",
  "Your daily and monthly budget per agent",
  "Your current database layout (optional)"
 ],
 "you_get": [
  "A step-by-step wrapper plan with the error each step returns",
  "A cost record layout, with columns to add to the starter",
  "Budget rules for each cap, including who can raise it",
  "A failure checklist and test cases"
 ],
 "use_when": [
  "You have more than one agent calling AI models and no single place that shows their spend.",
  "You want a hard daily or monthly limit that a runaway loop cannot get past.",
  "You want to see spend split by job, such as chat, audits or monitoring.",
  "You are about to add a tool-using agent and want its total cost counted as one."
 ],
 "skip_when": [
  "You want a limit set by rules per agent and per day. Use the Agent spending cap builder, which covers the policy side.",
  "You want to bill clients to the cent. This records costs for your own control, so reconcile against the provider's invoice first.",
  "You are not building code. For cutting AI costs in a normal chat, ask your AI to shorten your prompts instead.",
  "You want to run the jobs in the background. Use the Recoverable agent job queue builder."
 ],
 "output_sample": {
  "input": [
   "The AI models you plan to use, and the provider's current prices",
   "The job labels each call may carry",
   "A typical call size in tokens (optional)",
   "Your daily and monthly budget per agent"
  ],
  "prerequisites": [
   "An AI that can read your code files, or code pasted into the chat",
   "A database where call records can be saved"
  ],
  "output": [
   {
    "name": "BASIS",
    "contains": "What was read, what was left out and every missing input, with what each gap stops."
   },
   {
    "name": "WRAPPER PLAN",
    "contains": "The steps of one AI call, from the budget check to the saved record, with the error each returns."
   },
   {
    "name": "COST RECORD",
    "contains": "The columns saved for each call, including the ones to add to the starter layout."
   },
   {
    "name": "BUDGET RULES",
    "contains": "Each cap, who it covers, what happens at the limit and who may raise it."
   },
   {
    "name": "FAILURE CHECKLIST",
    "contains": "Refused, failed, timed-out and cancelled calls, with what is recorded for each."
   },
   {
    "name": "TEST CASES",
    "contains": "Cases such as a call just over the cap, an unknown label and two calls at the same moment."
   },
   {
    "name": "NEXT STEP",
    "contains": "The one smallest step to take next, such as adding the reserve step before the call."
   }
  ]
 },
 "output_shape": "BASIS\n<what was read>\nMISSING: <each missing input and what it stops>\n\nWRAPPER PLAN\n<step> | <what happens> | <where in your code> | <error returned>\n\nCOST RECORD\n<column> | <meaning> | <source>\n\nBUDGET RULES\n<cap> | <scope> | <what happens at the limit> | <who can raise it>\n\nFAILURE CHECKLIST\n<failure> | <what is recorded> | <what the caller sees> | <who checks it>\n\nTEST CASES\n<name> | <set-up> | <expected result>\n\nNEXT STEP\n<the smallest useful thing to do now>\n\nCHECKS MISSED\n<one line each, or none>",
 "how_to_use": [
  "Open the skill in an AI that can read your code, such as Claude Code or Codex. A plain chat works if you paste the files in.",
  "Paste your model list, your job labels and your budget. Get the model prices from the provider's price page and paste them too. Never paste an API key.",
  "Add your database layout if you have one. If you don't, the skill uses its starter layout and says so.",
  "Read BUDGET RULES first. Check each cap, who can raise it and what happens at the limit.",
  "Check COST RECORD against your provider's invoice for one real day before trusting any total.",
  "Run the test cases in your own project. This skill never runs code."
 ],
 "checks": [],
 "next": [
  {
   "name": "Simple code coach",
   "url": "https://useaiblocks.com/skills/simple-code-coach",
   "why": "Build it"
  }
 ],
 "source": null,
 "credits": [],
 "files": [
  "references/ai-cost-tracking-schema.sql",
  "references/method-notes.md"
 ],
 "links": {
  "page": "https://useaiblocks.com/skills/your-agent-s-first-ai-call-implementation-planner",
  "markdown": "https://useaiblocks.com/skills/your-agent-s-first-ai-call-implementation-planner.md",
  "json": "https://useaiblocks.com/skills/your-agent-s-first-ai-call-implementation-planner.json",
  "instructions": "https://useaiblocks.com/skills/your-agent-s-first-ai-call-implementation-planner/SKILL.md",
  "download": "https://useaiblocks.com/skills/your-agent-s-first-ai-call-implementation-planner.zip",
  "api_item": "https://useaiblocks.com/api/v1/items/your-agent-s-first-ai-call-implementation-planner",
  "api_document": "https://useaiblocks.com/api/v1/documents/skill/your-agent-s-first-ai-call-implementation-planner",
  "mcp": "https://useaiblocks.com/mcp"
 }
}
