---
title: "Recalculate log costs"
method: POST
path: "/api/logs/recalculate-cost"
tags: ["Logging"]
---

# Recalculate log costs

`POST /api/logs/recalculate-cost`

Starts an asynchronous background job that recalculates log costs in batches.
The returned payload is a job status object that can be polled via the status endpoint.

## Request body

- RecalculateCostRequest — Recalculate cost request
  - `filters` object — Log search filters
    - `providers` string[]
    - `models` string[]
    - `status` string[]
    - `objects` string[]
    - `selected_key_ids` string[]
    - `virtual_key_ids` string[]
    - `routing_rule_ids` string[]
    - `routing_engine_used` string[] — Filter by routing engine (routing-rule, governance, or loadbalancing)
    - `start_time` string, date-time
    - `end_time` string, date-time
    - `min_latency` number
    - `max_latency` number
    - `min_tokens` integer
    - `max_tokens` integer
    - `min_cost` number
    - `max_cost` number
    - `missing_cost_only` boolean
    - `content_search` string
  - `limit` integer — Maximum number of logs to process (default 200, max 1000)

## Response `202`

Cost recalculation job accepted

- RecalculateCostResponse — Recalculate cost job status
  - `id` string — Background job ID
  - `status` string — Current job status
  - `total` integer — Total matching logs queued for recalculation
  - `processed` integer — Logs processed so far
  - `updated` integer — Logs updated with new costs
  - `skipped` integer — Logs skipped during processing
  - `message` string — Optional progress message
  - `last_error` string — Last error encountered by the job
  - `started_at` string, date-time — Job start time
  - `updated_at` string, date-time — Last status update time

## Other responses

- `400` — Bad request
- `409` — A recalculation job is already running
- `500` — Internal server error
- `503` — Background job runner is not available

---

[API](https://skmtc.net/getbifrost/apis/bifrost-api.md) · [All operations](https://skmtc.net/getbifrost/apis/bifrost-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/getbifrost/bifrost-api/versions/f8cab88f64ea/schema)
