{
 "openapi": "3.1.0",
 "info": {
  "title": "Agent Cost Log",
  "version": "1.0.0",
  "description": "Cost log for AI agents. One call, or your OpenTelemetry export, turns into cost per run, per tool, per model and per day, with 30-day history. No evals, no prompts, no proxy. Free watch-only mode logs and flags runs over your cap; Pro at $9 a month posts the alert and keeps 30 days. Free 500/day; Pro $9/month: undefined"
 },
 "servers": [
  {
   "url": "https://costlog.cloudforbots.com"
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  }
 },
 "paths": {
  "/api/run/log_costs": {
   "post": {
    "operationId": "log_costs",
    "summary": "Log what your agent's model and tool calls cost, then get the running total for the run and for today",
    "description": "Log what your agent's model and tool calls cost, then get the running total for the run and for today. Pass events (one per call, up to 500) or an OpenTelemetry OTLP/JSON trace export as otel (gen_ai.usage.input_tokens / output_tokens / gen_ai.request.model are read; trace id becomes run_id). Give cost_usd per call, or tokens plus your own per-million prices; nothing is guessed. Optional caps: run_cap_usd and daily_cap_usd. Free watch-only returns would_alert when a cap is crossed; Pro posts one alert per day to alert_webhook. Never blocks or changes your agent.",
    "security": [
     {},
     {
      "bearer": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "run_id": {
          "type": "string",
          "description": "Stable id for this run (default \"default\")."
         },
         "events": {
          "type": "array",
          "items": {
           "type": "object",
           "properties": {
            "tool": {
             "type": "string",
             "description": "Tool or step name, e.g. \"web_search\"."
            },
            "model": {
             "type": "string",
             "description": "Model name as your provider bills it."
            },
            "agent": {
             "type": "string"
            },
            "input_tokens": {
             "type": "integer"
            },
            "output_tokens": {
             "type": "integer"
            },
            "cost_usd": {
             "type": "number",
             "description": "What the call cost, if your provider returns it. Otherwise pass tokens plus price_in_per_m / price_out_per_m."
            },
            "price_in_per_m": {
             "type": "number",
             "description": "Your input price in USD per 1M tokens (from your provider's price page)."
            },
            "price_out_per_m": {
             "type": "number",
             "description": "Your output price in USD per 1M tokens."
            },
            "run_id": {
             "type": "string"
            },
            "at": {
             "type": "string",
             "description": "ISO time of the call (default now; at most 30 days back)."
            }
           }
          }
         },
         "otel": {
          "type": "object",
          "description": "OTLP/JSON export: { resourceSpans: [...] }."
         },
         "price_in_per_m": {
          "type": "number",
          "description": "Default input USD per 1M tokens for events without cost_usd."
         },
         "price_out_per_m": {
          "type": "number",
          "description": "Default output USD per 1M tokens."
         },
         "run_cap_usd": {
          "type": "number"
         },
         "daily_cap_usd": {
          "type": "number"
         },
         "alert_webhook": {
          "type": "string",
          "description": "https URL Pro posts the cap alert to."
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result with job, understood, outcome, usage",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "401": {
      "description": "bad_agent_key"
     },
     "429": {
      "description": "free_limit_reached (includes upgrade link)"
     }
    }
   }
  },
  "/api/run/cost_report": {
   "post": {
    "operationId": "cost_report",
    "summary": "Cost per run, per tool, per model and per day",
    "description": "Cost per run, per tool, per model and per day. Without an API key pass run_id (one run). With a key: everything on that key. Free shows 7 days, Pro 30.",
    "security": [
     {},
     {
      "bearer": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "run_id": {
          "type": "string"
         },
         "days": {
          "type": "integer",
          "description": "1-30 (free max 7)."
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result with job, understood, outcome, usage",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "401": {
      "description": "bad_agent_key"
     },
     "429": {
      "description": "free_limit_reached (includes upgrade link)"
     }
    }
   }
  },
  "/api/run/weekly_report": {
   "post": {
    "operationId": "weekly_report",
    "summary": "Plain-English summary of the last 7 days of spend: total, top runs, top tools, top models, busiest day",
    "description": "Plain-English summary of the last 7 days of spend: total, top runs, top tools, top models, busiest day. Read-only; sends nothing. Needs a free API key.",
    "security": [
     {},
     {
      "bearer": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {}
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Result with job, understood, outcome, usage",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "401": {
      "description": "bad_agent_key"
     },
     "429": {
      "description": "free_limit_reached (includes upgrade link)"
     }
    }
   }
  },
  "/api/key": {
   "post": {
    "operationId": "get_free_key",
    "summary": "Get a free API key",
    "responses": {
     "200": {
      "description": "api_key"
     }
    }
   }
  }
 }
}