API: metering
GET /api/v1/metering/costs/by-article
Section titled “GET /api/v1/metering/costs/by-article”Costs By Article
Per-article cost for a contract: direct spend + amortized collect share.
direct = sum over the article’s own runs (generate/publish, where
generated_article_id is set). amortized_collect = the contract’s
contract-level cost (its collect runs, where generated_article_id IS
NULL) divided by the number of articles in the window — (owner
decision: amortize by period, not per collect-run, since collect feeds the
reused RAG corpus). imagegen is a deliberately separate ledger and NOT added.
Auth: Authorization: Bearer <token> required
| Parameter | In | Required | Type | Description |
|---|---|---|---|---|
salescontracts_id | query | yes | integer | |
from | query | no | string | null | |
to | query | no | string | null |
Responses:
| Code | Meaning | Body |
|---|---|---|
200 | Successful Response | array of ArticleCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/by-contract
Section titled “GET /api/v1/metering/costs/by-contract”Costs By Contract
Per-contract cost rollup (sum over each salescontracts_id).
Auth: Authorization: Bearer <token> required
| Parameter | In | Required | Type | Description |
|---|---|---|---|---|
ai_company_id | query | no | integer | null | |
from | query | no | string | null | |
to | query | no | string | null |
Responses:
| Code | Meaning | Body |
|---|---|---|
200 | Successful Response | array of ContractCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/by-pipeline-run
Section titled “GET /api/v1/metering/costs/by-pipeline-run”Costs By Pipeline Run
Per-run cost rows, newest first.
Auth: Authorization: Bearer <token> required
| Parameter | In | Required | Type | Description |
|---|---|---|---|---|
ai_company_id | query | no | integer | null | |
from | query | no | string | null | |
to | query | no | string | null | |
limit | query | no | integer | |
offset | query | no | integer |
Responses:
| Code | Meaning | Body |
|---|---|---|
200 | Successful Response | array of RunCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/summary
Section titled “GET /api/v1/metering/costs/summary”Costs Summary
Cost + tokens + brave aggregated by day / contract / model / provider.
Auth: Authorization: Bearer <token> required
| Parameter | In | Required | Type | Description |
|---|---|---|---|---|
group_by | query | no | "day" | "contract" | "model" | "provider" | |
ai_company_id | query | no | integer | null | |
from | query | no | string | null | |
to | query | no | string | null |
Responses:
| Code | Meaning | Body |
|---|---|---|
200 | Successful Response | array of CostSummaryRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |