List Cache Policies
GET /environments/{env_id}/cache_policies
GET /environments/{env_id}/cache_policiesInteractive request editor loads with JavaScript.
Authorization
BearerAdminToken Organization-scoped admin token. Read operations require a valid token, and write operations require a token with write permission.
In: header
Path Parameters
Environment ID that scopes the request.
uuidResponse Body
application/json
application/json
application/json
application/json
curl -X GET "$AISIX_CP/environments/$ENV_ID/cache_policies" \ -H "Authorization: Bearer $AISIX_TOKEN"OK
{
"data": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"env_id": "3f917d0d-4dff-42f3-97c4-6a5455dfe8c2",
"name": "string",
"enabled": true,
"backend": "memory",
"ttl_seconds": 0,
"applies_to": "string",
"scope": "api_key",
"purge_generation": 0,
"semantic": {
"embedding_model_id": "2959178f-981f-441b-a0b6-cedb1eb6201d",
"threshold": 0,
"max_entries": 1,
"embedding_timeout_ms": 0
},
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}Request body or parameters failed validation.
{
"error": {
"code": "string",
"message": "string"
}
}Missing or invalid bearer.
{
"error": {
"code": "UNAUTHENTICATED",
"message": "no org context"
}
}Resource not found.
{
"error": {
"code": "NOT_FOUND",
"message": "provider key not found"
}
}Complete operation details and schema variants
GET /environments/{env_id}/cache_policies
List Cache Policies
Return every prompt-response cache policy configured in the environment. The response is not paginated.
Parameters
env_id(path, string, required): Environment ID that scopes the request.
Responses
-
200: OK -
data(array, required): Cache policies in the environment, oldest first. -
data[].id(string, required): Cache policy ID. -
data[].env_id(string, required): Environment ID that owns this policy. -
data[].name(string, required): Human-readable policy name, unique within the environment. Fixed at creation. -
data[].enabled(boolean, required): Disabled policies are kept but the gateway no longer consults them. -
data[].backend(string, required): Where cached responses are stored.memorykeeps an in-process cache on each gateway instance.redisuses the shared Redis configured on the gateway (cache.redis); a gateway without one disables caching for the policy's requests and logs a warning. Fixed at creation. -
data[].ttl_seconds(integer, required): How long a cached response stays servable, in seconds. -
data[].applies_to(string, required): Which traffic the policy covers:allfor every request in the environment,model:<model alias>for one model, orapi_key:<key id>for one caller API key. -
data[].scope(string, required): Sharing boundary for entries created under a policy, applied to both exact and semantic matching.api_key(the default) keeps entries private to the API key that created them — one caller's answers are never replayed to another.envshares entries across every API key in the environment; pick it for shared-knowledge traffic (FAQ, documentation Q&A) where cross-caller reuse is the point. -
data[].purge_generation(integer, required): Server-managed invalidation counter. Each purge increments it, making every entry created earlier unreachable at once. Read-only — see the purge operation. -
data[].semantic(object, optional): Embedding-similarity matching for a cache policy. When configured, a request that misses exact matching is embedded and compared against stored entries; the nearest entry at or abovethresholdcosine similarity is served. Only fully textual requests participate — requests containing images, audio, or tool calls always take the exact path. On theredisbackend this additionally requires a Redis server with vector search (Redis 8 or later, or the search module); the gateway probes support at startup and keeps the policy exact-only when it is missing. -
data[].semantic.embedding_model_id(string, required): ID of the embedding model used to embed requests. Must reference a model of kindembeddingin the same environment. -
data[].semantic.threshold(number, required): Minimum cosine similarity for a stored entry to be served. Higher is stricter; values below0.9noticeably increase wrong-answer risk for most embedding models. -
data[].semantic.max_entries(integer, optional): Upper bound on stored entries for this policy on thememorybackend (oldest evicted first). Defaults to1000. Theredisbackend bounds growth by TTL and ignores this value. -
data[].semantic.embedding_timeout_ms(integer, optional): Per-call deadline for the embedding request in milliseconds.0or omitted disables the embedding-specific deadline. On timeout the request proceeds to the upstream uncached. -
data[].created_at(string, required): Time when the policy was created. -
data[].updated_at(string, required): Time when the policy was last updated. -
400: Request body or parameters failed validation. -
error(object, required): Error details. -
error.code(string, required): Machine-readable identifier. Examples:UNAUTHENTICATED,INVALID_REQUEST,MASTER_KEY_UNSET,INTERNAL. -
error.message(string, required): Human-readable explanation; safe to surface to operators. -
401: Missing or invalid bearer. Response fields (application/json): identical toGET /environments/{env_id}/cache_policies, response 400 above. -
404: Resource not found. Response fields (application/json): identical toGET /environments/{env_id}/cache_policies, response 400 above.
cURL
curl -X GET '$AISIX_CP/environments/{env_id}/cache_policies' -H 'Authorization: Bearer $AISIX_TOKEN'