openmeter icon indicating copy to clipboard operation
openmeter copied to clipboard

feat(invoice): cost, internal cost and margin

Open hekike opened this issue 3 months ago • 1 comments

Cost

GET /api/v1/billing/invoices/{"invoiceId}/lines/{lineId}/cost?windowSize=HOUR

{
  "cost": "2.4",
  "costPerUnit": "0.0000119845997893",
  "currency": "USD",
  "from": "2025-10-11T16:36:43Z",
  "internalCost": "2.00257",
  "internalCostPerUnit": "0.8344041666666667",
  "margin": "0.39743",
  "marginRate": "0.1655958333333333",
  "rows": [
    {
      "cost": "1.1208477106944932",
      "costPerUnit": "0.0000119845997893",
      "groupBy": {},
      "internalCost": "0.93524",
      "internalCostPerUnit": "0.00001",
      "margin": "0.1856077106944932",
      "marginRate": "0.1655958333353672",
      "usage": "93524",
      "windowEnd": "2025-10-11T17:00:00Z",
      "windowStart": "2025-10-11T16:00:00Z"
    },
    {
      "cost": "1.2791522893113569",
      "costPerUnit": "0.0000119845997893",
      "groupBy": {},
      "internalCost": "1.06733",
      "internalCostPerUnit": "0.00001",
      "margin": "0.2118222893113569",
      "marginRate": "0.1655958333353672",
      "usage": "106733",
      "windowEnd": "2025-10-11T19:00:00Z",
      "windowStart": "2025-10-11T18:00:00Z"
    }
  ],
  "to": "2025-11-11T16:36:43Z",
  "usage": "200257"
}

Feature

GET /api/v1/features/ai_gpt_5_input_tokens

{
  "id": "01K7A229QEBS3HXA51BCVZ38TR",
  "key": "ai_gpt_5_input_tokens",
  "name": "GPT-5 Input Tokens",
  "costPerUnit": "0.00000125",
  "createdAt": "2025-10-11T16:36:06.510673Z",
  "meterSlug": "tokens_total",
  "meterGroupByFilters": {
    "model": "gpt-5",
    "provider": "openai",
    "type": "input"
  },
  "advancedMeterGroupByFilters": {
    "model": {
      "$eq": "gpt-5"
    },
    "provider": {
      "$eq": "openai"
    },
    "type": {
      "$eq": "input"
    }
  },
  "updatedAt": "2025-10-11T16:36:06.510673Z"
}

hekike avatar Oct 11 '25 18:10 hekike

[!IMPORTANT]

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch feat/invoice-cost-model-cost

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 11 '25 18:10 coderabbitai[bot]