---
title: "Estimate analysis cost without starting a run"
method: POST
path: "/api/v1/contexts/{context_id}/analyses/preview"
tags: ["analyses"]
---

# Estimate analysis cost without starting a run

`POST /api/v1/contexts/{context_id}/analyses/preview`

## Request

- Base URL: `https://memory.kagura-ai.com` (the document declares no server; this is the origin it was published from)
- URL: `https://memory.kagura-ai.com/api/v1/contexts/{context_id}/analyses/preview`
- Auth: none declared

Returns the cost estimate for a hypothetical run.

Goes through the full 4-gate chain so a non-Pro / quota-exhausted
/ non-allowlisted user gets the same 403/429 they would on POST,
rather than seeing the price and then being blocked at confirm.

## Path parameters

- `context_id` string, uuid, required

## Headers

- `authorization` string, nullable

## Request body

- AnalysisPreviewRequest: Pre-flight cost-estimate request body. Mirrors the POST body so the modal in #497 can submit the same payload twice (preview, then run on confirm) without re-shaping. Empty body is valid — the preview falls back to the count of every memory in the context.
  - `from` string, nullable
  - `to` string, nullable
  - `types` string[], nullable
  - `tags` string[], nullable
  - `min_importance` number, nullable
  - `query` string, nullable
  - `model_id` integer, nullable

## Response `200`

Successful Response

- AnalysisPreviewResponse: Cost-estimate output (Stage [A] from preview.py). ``estimated_cost_cents`` is ``null`` when no price is configured for the model (#1570) — the estimate is unavailable, not zero — or when the deployment disables cost display (``ENABLE_COST_DISPLAY=false``, #1571).
  - `memory_count` integer, required
  - `cluster_count_estimate` integer, required
  - `estimated_cost_cents` integer, nullable, required
  - `model_id` string, required
  - `breakdown` object, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud.md) · [All operations](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/llms.txt) · [OpenAPI document](https://skmtc.dev/kagura-ai/apis/kagura-memory-cloud/revisions/09f17f5ada29?raw)
