You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "janiussyafiq (via GitHub)" <gi...@apache.org> on 2026/05/22 16:28:09 UTC

[PR] feat: ai-cache plugin (minimal exact cache for openai-chat) [PR-1] [apisix]

janiussyafiq opened a new pull request, #13424:
URL: https://github.com/apache/apisix/pull/13424

   ### Description
   
   PR-1 of the ai-cache phased series (RFC #13290, supersedes #13308 / #13370): a minimal exact-match L1 cache for `openai-chat` backed by Redis. Two phase hooks — `access` short-circuits on HIT, `log` schedules an `ngx.timer.at(0)` SETEX on 2xx JSON ≤ 1 MiB (cosockets are forbidden in `log_by_lua`). Priority `1086` runs above `ai-proxy=1040` so hits skip the upstream entirely. Cache key is `sha256({model, messages})` — the rest of the field whitelist, effective-body input, scoping, bypass header, and Prometheus arrive in PR-2 → PR-5.
   
   `apisix/plugins/ai-providers/base.lua` gets a one-line stash (`ctx.llm_raw_response_body = raw_res_body`) so the log phase can see the parsed envelope without a `body_filter`.
   
   Fail-open invariant holds: Redis errors degrade to MISS, never 5xx.
   
   #### Which issue(s) this PR fixes:
   
   Refs #13290
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: ai-cache plugin (exact-match cache for openai-chat) [apisix]

Posted by "janiussyafiq (via GitHub)" <gi...@apache.org>.
janiussyafiq closed pull request #13424: feat: ai-cache plugin (exact-match cache for openai-chat)
URL: https://github.com/apache/apisix/pull/13424


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: ai-cache plugin (exact-match cache for openai-chat) [apisix]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #13424:
URL: https://github.com/apache/apisix/pull/13424#discussion_r3377582057


##########
conf/config.yaml.example:
##########
@@ -519,6 +520,7 @@ plugins:                           # plugin list (sorted by priority)
   - data-mask                      # priority: 1500
   #- error-log-logger              # priority: 1091
   - proxy-cache                    # priority: 1085
+  - ai-cache                       # priority: 1086

Review Comment:
   This plugin list is annotated as “sorted by priority”, but `ai-cache` (priority 1086) is currently placed after `proxy-cache` (1085). Please reorder these two entries to keep the list consistent with the documented ordering.



##########
apisix/plugins/ai-cache.lua:
##########
@@ -0,0 +1,197 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core         = require("apisix.core")
+local schema_mod   = require("apisix.plugins.ai-cache.schema")
+local base         = require("apisix.plugins.ai-proxy.base")
+local key_mod      = require("apisix.plugins.ai-cache.key")
+local redis        = require("apisix.utils.redis")
+local rediscluster = require("apisix.utils.rediscluster")
+local ngx          = ngx
+local ngx_timer_at = ngx.timer.at
+
+local plugin_name = "ai-cache"
+
+-- Hardcoded in Phase 1a; Phase 1e makes these schema fields.
+local STATUS_HEADER       = "X-AI-Cache-Status"
+local MAX_CACHE_BODY_SIZE = 1048576   -- 1 MiB
+
+
+local function get_client(conf)
+    if conf.policy == "redis-cluster" then
+        local cli, err = rediscluster.new(conf, "plugin-ai-cache-redis-cluster-slot-lock")
+        return cli, err, "cluster"
+    end
+    local cli, err = redis.new(conf)
+    return cli, err, "single"
+end
+
+
+local function release(cli, mode, conf)
+    if mode == "cluster" then
+        -- rediscluster keeps its own pool
+        return
+    end
+    cli:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)

Review Comment:
   `set_keepalive` return value is ignored. If `set_keepalive` fails, the Redis connection may not be returned to the pool (potential connection leak) and the failure will be silent, making issues hard to diagnose. Please capture and log the error (same pattern used in existing Redis-backed plugins).



##########
docs/en/latest/plugins/ai-cache.md:
##########
@@ -0,0 +1,125 @@
+---
+title: ai-cache
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-cache
+  - AI
+  - LLM
+description: The ai-cache Plugin caches LLM responses and serves them on identical requests, reducing upstream cost and latency.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/ai-cache" />
+</head>
+
+## Description
+
+The `ai-cache` Plugin caches responses from LLM services and serves them directly when an identical request arrives again, reducing upstream token cost and response latency. It is used together with the [`ai-proxy`](./ai-proxy.md) or [`ai-proxy-multi`](./ai-proxy-multi.md) Plugin.
+
+The Plugin computes a SHA-256 cache key from the request and looks it up in Redis before the request is forwarded upstream. On a **hit**, the cached response is returned directly and the upstream is never contacted. On a **miss**, the request is proxied normally and a successful JSON response is written to the cache for subsequent requests.
+
+This release implements an **exact-match cache** for the `openai-chat` protocol. All `openai-chat`-compatible providers (for example Azure OpenAI, DeepSeek, OpenRouter, Together, vLLM, Ollama) are cached transparently because they share the protocol.
+
+:::note
+
+The cache key is currently derived from the **client-sent** request body — operator-side overrides applied by `ai-proxy` (such as a `model` override) are not yet reflected in the key. If a route applies such overrides, flush the cache (or use a dedicated Redis database) before relying on cache correctness.
+
+:::

Review Comment:
   The note claims the cache key is derived from the client-sent request body and does not reflect `ai-proxy` instance overrides. In this PR, `ai-cache` explicitly hashes the *effective* (post-override) request via `effective_request_for_cache`, so this warning is now inaccurate and could mislead operators.



##########
docs/en/latest/plugins/ai-cache.md:
##########
@@ -0,0 +1,125 @@
+---
+title: ai-cache
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-cache
+  - AI
+  - LLM
+description: The ai-cache Plugin caches LLM responses and serves them on identical requests, reducing upstream cost and latency.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/ai-cache" />
+</head>
+
+## Description
+
+The `ai-cache` Plugin caches responses from LLM services and serves them directly when an identical request arrives again, reducing upstream token cost and response latency. It is used together with the [`ai-proxy`](./ai-proxy.md) or [`ai-proxy-multi`](./ai-proxy-multi.md) Plugin.
+
+The Plugin computes a SHA-256 cache key from the request and looks it up in Redis before the request is forwarded upstream. On a **hit**, the cached response is returned directly and the upstream is never contacted. On a **miss**, the request is proxied normally and a successful JSON response is written to the cache for subsequent requests.
+
+This release implements an **exact-match cache** for the `openai-chat` protocol. All `openai-chat`-compatible providers (for example Azure OpenAI, DeepSeek, OpenRouter, Together, vLLM, Ollama) are cached transparently because they share the protocol.
+
+:::note
+
+The cache key is currently derived from the **client-sent** request body — operator-side overrides applied by `ai-proxy` (such as a `model` override) are not yet reflected in the key. If a route applies such overrides, flush the cache (or use a dedicated Redis database) before relying on cache correctness.
+
+:::
+
+## Attributes
+
+| Name                       | Type            | Required                          | Default | Valid values         | Description                                                                                          |
+|----------------------------|-----------------|-----------------------------------|---------|----------------------|------------------------------------------------------------------------------------------------------|
+| exact.ttl                  | integer         | False                             | 3600    | 1 to 2592000         | Time-to-live in seconds for a cached response.                                                       |
+| policy                     | string          | True                              | redis   | redis, redis-cluster | Backend used to store cached responses.                                                              |
+| redis_host                 | string          | True when `policy` is `redis`     |         |                      | Address of the Redis node.                                                                           |
+| redis_port                 | integer         | False                             | 6379    | greater than 0       | Port of the Redis node.                                                                              |
+| redis_password             | string          | False                             |         |                      | Password for Redis authentication.                                                                   |
+| redis_database             | integer         | False                             | 0       | greater than or equal to 0 | Redis database to use when `policy` is `redis`.                                                |
+| redis_timeout              | integer         | False                             | 1000    | greater than 0       | Redis connection/read/write timeout in milliseconds.                                                 |
+| redis_cluster_nodes        | array[string]   | True when `policy` is `redis-cluster` |     |                      | List of Redis cluster node addresses, used when `policy` is `redis-cluster`.                         |
+| redis_cluster_name         | string          | True when `policy` is `redis-cluster` |     |                      | Name of the Redis cluster, used when `policy` is `redis-cluster`.                                    |
+| redis_cluster_ssl          | boolean         | False                             | false   |                      | If true, use SSL to connect to the Redis cluster.                                                    |
+| redis_cluster_ssl_verify   | boolean         | False                             | false   |                      | If true, verify the Redis cluster SSL certificate.                                                   |

Review Comment:
   The plugin schema (via `apisix.utils.redis-schema`) supports additional Redis connection fields (for example `redis_username`, `redis_ssl`, `redis_ssl_verify`, and keepalive settings), and `ai-cache` also uses `redis_keepalive_timeout/pool` at runtime. The Attributes table should document these options for parity with other Redis-backed plugin docs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: ai-cache plugin (exact-match cache for openai-chat) [apisix]

Posted by "janiussyafiq (via GitHub)" <gi...@apache.org>.
janiussyafiq commented on PR #13424:
URL: https://github.com/apache/apisix/pull/13424#issuecomment-4747580409

   Closing — restarting the `ai-cache` plugin from a fresh, decomposed design. A new technical RFC splits the work into smaller, independently reviewable PRs (exact cache first, then semantic, streaming, observability), keyed on the request fingerprint. New PRs will follow. Thanks for the earlier review that prompted the split.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: ai-cache plugin (exact-match cache for openai-chat) [apisix]

Posted by "janiussyafiq (via GitHub)" <gi...@apache.org>.
janiussyafiq commented on code in PR #13424:
URL: https://github.com/apache/apisix/pull/13424#discussion_r3382998848


##########
apisix/plugins/ai-cache.lua:
##########
@@ -0,0 +1,197 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core         = require("apisix.core")
+local schema_mod   = require("apisix.plugins.ai-cache.schema")
+local base         = require("apisix.plugins.ai-proxy.base")
+local key_mod      = require("apisix.plugins.ai-cache.key")
+local redis        = require("apisix.utils.redis")
+local rediscluster = require("apisix.utils.rediscluster")
+local ngx          = ngx
+local ngx_timer_at = ngx.timer.at
+
+local plugin_name = "ai-cache"
+
+-- Hardcoded in Phase 1a; Phase 1e makes these schema fields.
+local STATUS_HEADER       = "X-AI-Cache-Status"
+local MAX_CACHE_BODY_SIZE = 1048576   -- 1 MiB
+
+
+local function get_client(conf)
+    if conf.policy == "redis-cluster" then
+        local cli, err = rediscluster.new(conf, "plugin-ai-cache-redis-cluster-slot-lock")
+        return cli, err, "cluster"
+    end
+    local cli, err = redis.new(conf)
+    return cli, err, "single"
+end
+
+
+local function release(cli, mode, conf)
+    if mode == "cluster" then
+        -- rediscluster keeps its own pool
+        return
+    end
+    cli:set_keepalive(conf.redis_keepalive_timeout, conf.redis_keepalive_pool)

Review Comment:
   Addressed in 8b698907 — `release()` now captures the `set_keepalive` return value and logs a warning on failure, matching the pattern in `limit-conn-redis` / `limit-count-redis`.



##########
docs/en/latest/plugins/ai-cache.md:
##########
@@ -0,0 +1,125 @@
+---
+title: ai-cache
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-cache
+  - AI
+  - LLM
+description: The ai-cache Plugin caches LLM responses and serves them on identical requests, reducing upstream cost and latency.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/ai-cache" />
+</head>
+
+## Description
+
+The `ai-cache` Plugin caches responses from LLM services and serves them directly when an identical request arrives again, reducing upstream token cost and response latency. It is used together with the [`ai-proxy`](./ai-proxy.md) or [`ai-proxy-multi`](./ai-proxy-multi.md) Plugin.
+
+The Plugin computes a SHA-256 cache key from the request and looks it up in Redis before the request is forwarded upstream. On a **hit**, the cached response is returned directly and the upstream is never contacted. On a **miss**, the request is proxied normally and a successful JSON response is written to the cache for subsequent requests.
+
+This release implements an **exact-match cache** for the `openai-chat` protocol. All `openai-chat`-compatible providers (for example Azure OpenAI, DeepSeek, OpenRouter, Together, vLLM, Ollama) are cached transparently because they share the protocol.
+
+:::note
+
+The cache key is currently derived from the **client-sent** request body — operator-side overrides applied by `ai-proxy` (such as a `model` override) are not yet reflected in the key. If a route applies such overrides, flush the cache (or use a dedicated Redis database) before relying on cache correctness.
+
+:::

Review Comment:
   Addressed in 8b698907 — the plugin doc was rewritten. The note now states the key is derived from the **effective** (post-override) request, so `ai-proxy`/`ai-proxy-multi` overrides are reflected and cannot cause cross-caching.



##########
docs/en/latest/plugins/ai-cache.md:
##########
@@ -0,0 +1,125 @@
+---
+title: ai-cache
+keywords:
+  - Apache APISIX
+  - API Gateway
+  - Plugin
+  - ai-cache
+  - AI
+  - LLM
+description: The ai-cache Plugin caches LLM responses and serves them on identical requests, reducing upstream cost and latency.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+<head>
+  <link rel="canonical" href="https://docs.api7.ai/hub/ai-cache" />
+</head>
+
+## Description
+
+The `ai-cache` Plugin caches responses from LLM services and serves them directly when an identical request arrives again, reducing upstream token cost and response latency. It is used together with the [`ai-proxy`](./ai-proxy.md) or [`ai-proxy-multi`](./ai-proxy-multi.md) Plugin.
+
+The Plugin computes a SHA-256 cache key from the request and looks it up in Redis before the request is forwarded upstream. On a **hit**, the cached response is returned directly and the upstream is never contacted. On a **miss**, the request is proxied normally and a successful JSON response is written to the cache for subsequent requests.
+
+This release implements an **exact-match cache** for the `openai-chat` protocol. All `openai-chat`-compatible providers (for example Azure OpenAI, DeepSeek, OpenRouter, Together, vLLM, Ollama) are cached transparently because they share the protocol.
+
+:::note
+
+The cache key is currently derived from the **client-sent** request body — operator-side overrides applied by `ai-proxy` (such as a `model` override) are not yet reflected in the key. If a route applies such overrides, flush the cache (or use a dedicated Redis database) before relying on cache correctness.
+
+:::
+
+## Attributes
+
+| Name                       | Type            | Required                          | Default | Valid values         | Description                                                                                          |
+|----------------------------|-----------------|-----------------------------------|---------|----------------------|------------------------------------------------------------------------------------------------------|
+| exact.ttl                  | integer         | False                             | 3600    | 1 to 2592000         | Time-to-live in seconds for a cached response.                                                       |
+| policy                     | string          | True                              | redis   | redis, redis-cluster | Backend used to store cached responses.                                                              |
+| redis_host                 | string          | True when `policy` is `redis`     |         |                      | Address of the Redis node.                                                                           |
+| redis_port                 | integer         | False                             | 6379    | greater than 0       | Port of the Redis node.                                                                              |
+| redis_password             | string          | False                             |         |                      | Password for Redis authentication.                                                                   |
+| redis_database             | integer         | False                             | 0       | greater than or equal to 0 | Redis database to use when `policy` is `redis`.                                                |
+| redis_timeout              | integer         | False                             | 1000    | greater than 0       | Redis connection/read/write timeout in milliseconds.                                                 |
+| redis_cluster_nodes        | array[string]   | True when `policy` is `redis-cluster` |     |                      | List of Redis cluster node addresses, used when `policy` is `redis-cluster`.                         |
+| redis_cluster_name         | string          | True when `policy` is `redis-cluster` |     |                      | Name of the Redis cluster, used when `policy` is `redis-cluster`.                                    |
+| redis_cluster_ssl          | boolean         | False                             | false   |                      | If true, use SSL to connect to the Redis cluster.                                                    |
+| redis_cluster_ssl_verify   | boolean         | False                             | false   |                      | If true, verify the Redis cluster SSL certificate.                                                   |

Review Comment:
   Addressed in 8b698907 — the attributes table now documents `redis_username`, `redis_ssl`, `redis_ssl_verify`, `redis_keepalive_timeout`, and `redis_keepalive_pool`.



##########
conf/config.yaml.example:
##########
@@ -519,6 +520,7 @@ plugins:                           # plugin list (sorted by priority)
   - data-mask                      # priority: 1500
   #- error-log-logger              # priority: 1091
   - proxy-cache                    # priority: 1085
+  - ai-cache                       # priority: 1086

Review Comment:
   Addressed — `ai-cache` (1086) is now ordered ahead of `proxy-cache` (1085) in `conf/config.yaml.example` (8b698907), and likewise in `apisix/cli/config.lua` (5a963d98).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: ai-cache plugin (exact-match cache for openai-chat) [apisix]

Posted by "janiussyafiq (via GitHub)" <gi...@apache.org>.
janiussyafiq commented on PR #13424:
URL: https://github.com/apache/apisix/pull/13424#issuecomment-4693267842

   **Restructure incoming: converging on a reference exact-match cache design — smaller, with zero shared-file changes.**
   
   Following up on the phase-1 direction requested in #13308 ("focus only on exact cache… make the cache key correct and conservative") and RFC #13290, I am reshaping this PR to shrink its review surface and remove **all** edits to `ai-proxy/base.lua`, `ai-providers/base.lua`, `apisix/cli/ngx_tpl.lua`, `apisix/utils/redis-schema.lua`, and `t/APISIX.pm`. The next push brings the diff from 2,395 additions / 15 files down to ~1,900 / 9 files, with production code down from ~510 to ~370 lines — all in new files, except one plugin-list line each in `cli/config.lua` and `config.yaml.example`.
   
   What changes and why:
   
   - **Key on the request as received**, scoped by `ctx.conf_id` + `ctx.conf_version`. This covers the "route/service/plugin config" context asked for in #13308 directly: any config edit (including an in-place `ai-proxy` model-override change) bumps `conf_version` and makes old entries unreachable — stricter than the previous instance-name scoping, which missed in-place override edits. The model and all generation parameters are hashed in the body; the effective-request computation, the provider-base refactor, and the failover write-skip guard are deleted entirely. Routes using `ai-proxy-multi` **bypass caching** in PR1, so one route = one fixed instance and cross-instance serving is impossible; multi-instance semantics get their own follow-up PR where that design can be discussed in isolation.
   - **Lookup moves from `before_proxy` (priority 1086) to `access` (priority 1028)**, following the existing `ai-aliyun-content-moderation` pattern, with the response captured via the plugin's own `lua_body_filter`. Hit/write semantics are unchanged, hits stay subject to `ai-rate-limiting` and request-side moderation, and this fixes an ordering issue where protocol detection at 1086 ran before `ai-request-rewrite` (1073) could mutate the body.
   - **Single-node Redis only**; `redis-cluster` (schema branch + slot-lock dict wiring) moves to a stacked follow-up, where it will also gain a real cluster round-trip test against the CI cluster service.
   - Kept deliberately: 2xx-only writes and hit/miss headers per RFC #13290, JSON validation + 1 MiB write cap, corrupt-entry cleanup, fail-open on every Redis/key error, temperature/top_p milli-quantisation, and `core.json.stably_encode` canonicalisation with SHA-256.
   
   **Stack:** ① `redis-schema` shared-table fix (separate small PR, opening now — it is a pre-existing bug this PR previously fixed in passing) → ② this PR → ③ redis-cluster support → ④ ai-proxy-multi semantics (draft, design question stated up front) → ⑤ RFC #13290 alignment (consumer scoping, `bypass_on`, headers schema, Prometheus metrics). Each stage is independently shippable, and every deferred behavior degrades to a cache MISS, never an incorrect hit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org