{
  "openapi": "3.1.0",
  "info": {
    "title": "AI Usage Export Analyzer API",
    "version": "2026-11-23",
    "description": "Reads OpenAI, Claude and gateway usage or cost exports and returns spend by model, project and day, the days that stood out, and what batch or another model would save. Nothing sent is kept. No key or account. Up to 5000000 bytes and 24 files a request."
  },
  "servers": [
    {
      "url": "https://tools.finitizer.com"
    }
  ],
  "paths": {
    "/ai-usage-analyzer/api": {
      "post": {
        "operationId": "analyzeUsageExport",
        "summary": "Analyze usage or cost exports",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "markdown for a report to paste into a chat.",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown"
              ]
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "description": "A name for a raw CSV body.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "files"
                ],
                "additionalProperties": false,
                "properties": {
                  "files": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 24,
                    "items": {
                      "type": "object",
                      "required": [
                        "name"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "inputIncludesCache": {
                          "type": "boolean",
                          "description": "Overrides the guess from the column names: true when input tokens already hold the cached ones (OpenAI), false when cache reads come on top (Anthropic)."
                        },
                        "text": {
                          "type": "string",
                          "description": "The file as text: CSV, or the JSON of a usage API."
                        },
                        "base64": {
                          "type": "string",
                          "description": "The file as base64, in place of text. Use this if a request with text is refused."
                        }
                      }
                    }
                  },
                  "batchShare": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "description": "Share of the traffic not yet in batch that could wait. Default 0.5."
                  },
                  "swapFrom": {
                    "type": "string",
                    "description": "A model in the files, for the move-to-another-model what-if."
                  },
                  "swapTo": {
                    "type": "string",
                    "description": "The model to move it to."
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "markdown"
                    ]
                  }
                }
              }
            },
            "text/csv": {
              "schema": {
                "type": "string",
                "description": "One file as the body."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report: totals, findings, warnings, spend by model, group and day, what-ifs, and how each file was read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "currency",
                    "spend",
                    "findings",
                    "warnings",
                    "byModel",
                    "files"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "description": "False when no file could be read: see files[].error."
                    },
                    "currency": {
                      "type": "string"
                    },
                    "spend": {
                      "type": "number",
                      "description": "Total spend: fromFiles plus estimatedAtListPrice. Leaves out unpricedTokens."
                    },
                    "fromFiles": {
                      "type": "number",
                      "description": "Spend as the cost files state it, never re-priced."
                    },
                    "estimatedAtListPrice": {
                      "type": "number",
                      "description": "Token-only rows priced at public list rates."
                    },
                    "listPriceInFiles": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "unpricedTokens": {
                      "type": "number",
                      "description": "Tokens with no cost in any file and no list price here."
                    },
                    "unpricedModels": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "period": {
                      "type": "object",
                      "properties": {
                        "first": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "last": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "days": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "wholeMonth": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      }
                    },
                    "perDay": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "perMonth": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "requests": {
                      "type": "number"
                    },
                    "tokens": {
                      "type": "object",
                      "properties": {
                        "inputNotFromCache": {
                          "type": "number"
                        },
                        "cacheRead": {
                          "type": "number"
                        },
                        "cacheWrite": {
                          "type": "number"
                        },
                        "output": {
                          "type": "number"
                        },
                        "totalOnly": {
                          "type": "number"
                        }
                      }
                    },
                    "cacheHitRate": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "cacheSaving": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "batchShare": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "findings": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "byModel": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "model": {
                            "type": "string"
                          },
                          "names": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "spend": {
                            "type": "number"
                          },
                          "share": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "basis": {
                            "type": "string",
                            "enum": [
                              "file",
                              "estimated",
                              "none",
                              "mixed",
                              "tokens"
                            ]
                          },
                          "tokens": {
                            "type": "number"
                          },
                          "requests": {
                            "type": "number"
                          },
                          "cacheHitRate": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        }
                      }
                    },
                    "groups": {
                      "type": "object",
                      "description": "Spend by project, apiKey, user, workspace, product or serviceTier, where the files have them."
                    },
                    "daily": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "unusualDays": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "usual": {
                            "type": "number"
                          },
                          "topModel": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "modelSpikes": {
                      "type": "array",
                      "description": "Days one model jumped while the account total did not.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "model": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "usual": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "whatIf": {
                      "type": "object",
                      "properties": {
                        "batch": {
                          "type": "object",
                          "properties": {
                            "share": {
                              "type": "number"
                            },
                            "eligibleSpend": {
                              "type": "number"
                            },
                            "saving": {
                              "type": "number"
                            }
                          }
                        },
                        "swap": {
                          "type": [
                            "object",
                            "null"
                          ],
                          "properties": {
                            "from": {
                              "type": "string"
                            },
                            "to": {
                              "type": "string"
                            },
                            "spent": {
                              "type": "number"
                            },
                            "projected": {
                              "type": "number"
                            },
                            "saving": {
                              "type": "number"
                            },
                            "longPrompt": {
                              "type": [
                                "string",
                                "null"
                              ],
                              "enum": [
                                "above",
                                "below",
                                "unknown",
                                null
                              ]
                            }
                          }
                        },
                        "swapNote": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Why no swap was priced when one was asked for."
                        }
                      }
                    },
                    "prices": {
                      "type": "object",
                      "properties": {
                        "catalogVersion": {
                          "type": "string"
                        },
                        "olderModelsReadOn": {
                          "type": "string"
                        },
                        "modelList": {
                          "type": "string"
                        }
                      }
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "layout": {
                            "type": "string"
                          },
                          "readAs": {
                            "type": "string"
                          },
                          "rows": {
                            "type": "number"
                          },
                          "skippedRows": {
                            "type": "number"
                          },
                          "unreadableCells": {
                            "type": "number"
                          },
                          "firstDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "lastDate": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "addedToSpend": {
                            "type": "boolean"
                          },
                          "columns": {
                            "type": "object"
                          },
                          "error": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The request is not valid."
          },
          "413": {
            "description": "The request is too large."
          },
          "422": {
            "description": "No file could be read. Each file says why."
          },
          "429": {
            "description": "More than 20 analyses a minute."
          }
        }
      }
    }
  },
  "externalDocs": {
    "url": "https://tools.finitizer.com/ai-usage-analyzer/data.json"
  }
}
