# Cache API

## GET /api/v1/admin/cache

`GET /api/v1/admin/cache` · operation `getExactCacheStatus`

Requires exact_cache and global providers:read (GET) or providers:manage plus CSRF (DELETE). Process-local only; no cache content, keys or fingerprints are exposed. Purge invalidates in-flight inserts, not another replica. Expiration/removal is opportunistic; no memory zeroization guarantee.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Process-local bounded cache metadata | `application/json`: [ExactCacheStatus](/docs/api/schemas/e/#exactcachestatus) |
| `400` | Invalid bounded request | — |
| `401` | Authentication required | — |
| `403` | Role or resource forbidden | — |
| `404` | Feature disabled or resource unavailable | — |
| `409` | Version or trust conflict | — |
| `503` | Storage, trust or operation temporarily unavailable | — |


## DELETE /api/v1/admin/cache

`DELETE /api/v1/admin/cache` · operation `purgeExactCache`

Requires exact_cache and global providers:read (GET) or providers:manage plus CSRF (DELETE). Process-local only; no cache content, keys or fingerprints are exposed. Purge invalidates in-flight inserts, not another replica. Expiration/removal is opportunistic; no memory zeroization guarantee.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Process-local bounded cache metadata | `application/json`: [ExactCacheStatus](/docs/api/schemas/e/#exactcachestatus) |
| `400` | Invalid bounded request | — |
| `401` | Authentication required | — |
| `403` | Role or resource forbidden | — |
| `404` | Feature disabled or resource unavailable | — |
| `409` | Version or trust conflict | — |
| `503` | Storage, trust or operation temporarily unavailable | — |


## GET /api/v1/admin/semantic-cache

`GET /api/v1/admin/semantic-cache` · operation `getSemanticCacheStatus`

semantic_cache (ADR 0116). Requires global providers:read. Backend (postgres, shared by replicas; redis with distributed_semantic_cache, shared by replicas on the same namespace; or memory, this process), and per alias the policy and its live entries (-1 on redis, which keeps no inventory). No questions, answers or buckets are exposed. With distributed_semantic_cache and no Redis backend installed in this process the route answers 503; reading the status never contacts Redis.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Semantic cache policies and entry counts | `application/json`: [SemanticCacheStatus](/docs/api/schemas/s/#semanticcachestatus) |
| `401` | Authentication required | — |
| `403` | Role or resource forbidden | — |
| `404` | Feature disabled | — |
| `503` | Storage unavailable | — |


## DELETE /api/v1/admin/semantic-cache

`DELETE /api/v1/admin/semantic-cache` · operation `purgeSemanticCache`

Requires global providers:manage plus CSRF. Deletes every entry, or only those of one alias with ?model= (any name a configured model serves: an alias_of name purges its canonical model; a concrete wildcard name such as openai/gpt-4o purges that name, and the declared openai/* purges every name under the prefix; on Redis both rotate the generation of the declared entry). With PostgreSQL the purge reaches every replica. With distributed_semantic_cache it starts a new Redis generation for the alias (or for every alias): every replica stops reading the old entries on its next lookup, they expire with their TTL, and purged is -1; a Redis failure answers 503.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `model` | query | string | Alias whose entries are deleted; empty deletes all |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Status after the purge, with the number of deleted entries | `application/json`: [SemanticCacheStatus](/docs/api/schemas/s/#semanticcachestatus) |
| `401` | Authentication required | — |
| `403` | Role or resource forbidden | — |
| `404` | Feature disabled, or model_not_found: no configured model serves ?model=, so the purge would invalidate nothing | — |
| `503` | Purge could not be confirmed | — |

