API: metering
GET /api/v1/metering/costs/by-article
Заголовок раздела «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.
Авторизация: нужен Authorization: Bearer <token>
| Параметр | Где | Обязателен | Тип | Описание |
|---|---|---|---|---|
salescontracts_id | query | да | integer | |
from | query | нет | string | null | |
to | query | нет | string | null |
Ответы:
| Код | Смысл | Тело |
|---|---|---|
200 | Successful Response | массив ArticleCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/by-contract
Заголовок раздела «GET /api/v1/metering/costs/by-contract»Costs By Contract
Per-contract cost rollup (sum over each salescontracts_id).
Авторизация: нужен Authorization: Bearer <token>
| Параметр | Где | Обязателен | Тип | Описание |
|---|---|---|---|---|
ai_company_id | query | нет | integer | null | |
from | query | нет | string | null | |
to | query | нет | string | null |
Ответы:
| Код | Смысл | Тело |
|---|---|---|
200 | Successful Response | массив ContractCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/by-pipeline-run
Заголовок раздела «GET /api/v1/metering/costs/by-pipeline-run»Costs By Pipeline Run
Per-run cost rows, newest first.
Авторизация: нужен Authorization: Bearer <token>
| Параметр | Где | Обязателен | Тип | Описание |
|---|---|---|---|---|
ai_company_id | query | нет | integer | null | |
from | query | нет | string | null | |
to | query | нет | string | null | |
limit | query | нет | integer | |
offset | query | нет | integer |
Ответы:
| Код | Смысл | Тело |
|---|---|---|
200 | Successful Response | массив RunCostRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |
GET /api/v1/metering/costs/summary
Заголовок раздела «GET /api/v1/metering/costs/summary»Costs Summary
Cost + tokens + brave aggregated by day / contract / model / provider.
Авторизация: нужен Authorization: Bearer <token>
| Параметр | Где | Обязателен | Тип | Описание |
|---|---|---|---|---|
group_by | query | нет | "day" | "contract" | "model" | "provider" | |
ai_company_id | query | нет | integer | null | |
from | query | нет | string | null | |
to | query | нет | string | null |
Ответы:
| Код | Смысл | Тело |
|---|---|---|
200 | Successful Response | массив CostSummaryRow |
401 | Missing or invalid authentication credentials | ErrorResponse |
422 | Validation Error | HTTPValidationError |