kayx23 commented on code in PR #12036:
URL: https://github.com/apache/apisix/pull/12036#discussion_r2000460344


##########
docs/en/latest/plugins/ai-request-rewrite.md:
##########
@@ -0,0 +1,167 @@
+---
+title: ai-request-rewrite
+keywords:
+  - Apache APISIX
+  - AI Gateway
+  - Plugin
+  - ai-request-rewrite
+description: The ai-request-rewrite plugin intercepts client requests before 
they are forwarded to the upstream service. It sends a predefined prompt, along 
with the original request body, to a specified LLM service. The LLM processes 
the input and returns a modified request body, which is then used for the 
upstream request. This allows dynamic transformation of API requests based on 
AI-generated content.
+---
+
+<!--
+#
+# 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.
+#
+-->
+
+## Description
+
+The `ai-request-rewrite` plugin intercepts client requests before they are 
forwarded to the upstream service. It sends a predefined prompt, along with the 
original request body, to a specified LLM service. The LLM processes the input 
and returns a modified request body, which is then used for the upstream 
request. This allows dynamic transformation of API requests based on 
AI-generated content.
+
+## Plugin Attributes
+
+| **Field**                 | **Required** | **Type** | **Description**        
                                                              |
+| ------------------------- | ------------ | -------- | 
------------------------------------------------------------------------------------
 |
+| prompt                    | Yes          | String   | The prompt send to LLM 
service.                                                      |
+| provider                  | Yes          | String   | Name of the LLM 
service. Available options: openai, deekseek and openai-compatible   |
+| auth                      | Yes          | Object   | Authentication 
configuration                                                         |
+| auth.header               | No           | Object   | Authentication 
headers. Key must match pattern `^[a-zA-Z0-9._-]+$`.                  |
+| auth.query                | No           | Object   | Authentication query 
parameters. Key must match pattern `^[a-zA-Z0-9._-]+$`.         |
+| options                   | No           | Object   | Key/value settings for 
the model                                                     |
+| options.model             | No           | String   | Model to execute. 
Examples: "gpt-3.5-turbo" for openai, "deepseek-chat" for deekseek, or 
"qwen-turbo" for openai-compatible services |
+| override.endpoint         | No           | String   | Override the default 
endpoint when using OpenAI-compatible services (e.g., self-hosted models or 
third-party LLM services) |
+| timeout                   | No           | Integer  | Total timeout in 
milliseconds for requests to LLM service, including connect, send, and read 
timeouts. Range: 1 - 60000. Default: 3000|
+| keepalive                 | No           | Boolean  | Enable keepalive for 
requests to LLM service. Default: true                                  |
+| keepalive_timeout         | No           | Integer  | Keepalive timeout in 
milliseconds for requests to LLM service. Minimum: 1000. Default: 60000 |
+| keepalive_pool            | No           | Integer  | Keepalive pool size 
for requests to LLM service. Minimum: 1. Default: 30                     |
+| ssl_verify                | No           | Boolean  | SSL verification for 
requests to LLM service. Default: true                                  |
+
+## How it works
+
+![image](https://github.com/user-attachments/assets/c7288e4f-00fc-46ca-b69e-d3d74d7085ca)
+
+## Example usage
+
+Create a route with the `ai-request-rewrite` plugin like:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/routes/1"; -X PUT \
+  -H "X-API-KEY: ${ADMIN_API_KEY}" \

Review Comment:
   Replace `ADMIN_API_KEY` with `admin_key` in docs because apache/apisix docs 
use `admin_key`:
   
   <img width="828" alt="image" 
src="https://github.com/user-attachments/assets/4a2eb113-1bd1-4468-915c-c82a48666cf9";
 />
   



##########
docs/en/latest/plugins/ai-request-rewrite.md:
##########
@@ -0,0 +1,167 @@
+---
+title: ai-request-rewrite
+keywords:
+  - Apache APISIX
+  - AI Gateway
+  - Plugin
+  - ai-request-rewrite
+description: The ai-request-rewrite plugin intercepts client requests before 
they are forwarded to the upstream service. It sends a predefined prompt, along 
with the original request body, to a specified LLM service. The LLM processes 
the input and returns a modified request body, which is then used for the 
upstream request. This allows dynamic transformation of API requests based on 
AI-generated content.
+---
+
+<!--
+#
+# 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.
+#
+-->
+
+## Description
+
+The `ai-request-rewrite` plugin intercepts client requests before they are 
forwarded to the upstream service. It sends a predefined prompt, along with the 
original request body, to a specified LLM service. The LLM processes the input 
and returns a modified request body, which is then used for the upstream 
request. This allows dynamic transformation of API requests based on 
AI-generated content.
+
+## Plugin Attributes
+
+| **Field**                 | **Required** | **Type** | **Description**        
                                                              |
+| ------------------------- | ------------ | -------- | 
------------------------------------------------------------------------------------
 |
+| prompt                    | Yes          | String   | The prompt send to LLM 
service.                                                      |
+| provider                  | Yes          | String   | Name of the LLM 
service. Available options: openai, deekseek and openai-compatible   |
+| auth                      | Yes          | Object   | Authentication 
configuration                                                         |
+| auth.header               | No           | Object   | Authentication 
headers. Key must match pattern `^[a-zA-Z0-9._-]+$`.                  |
+| auth.query                | No           | Object   | Authentication query 
parameters. Key must match pattern `^[a-zA-Z0-9._-]+$`.         |
+| options                   | No           | Object   | Key/value settings for 
the model                                                     |
+| options.model             | No           | String   | Model to execute. 
Examples: "gpt-3.5-turbo" for openai, "deepseek-chat" for deekseek, or 
"qwen-turbo" for openai-compatible services |
+| override.endpoint         | No           | String   | Override the default 
endpoint when using OpenAI-compatible services (e.g., self-hosted models or 
third-party LLM services) |
+| timeout                   | No           | Integer  | Total timeout in 
milliseconds for requests to LLM service, including connect, send, and read 
timeouts. Range: 1 - 60000. Default: 3000|
+| keepalive                 | No           | Boolean  | Enable keepalive for 
requests to LLM service. Default: true                                  |
+| keepalive_timeout         | No           | Integer  | Keepalive timeout in 
milliseconds for requests to LLM service. Minimum: 1000. Default: 60000 |
+| keepalive_pool            | No           | Integer  | Keepalive pool size 
for requests to LLM service. Minimum: 1. Default: 30                     |
+| ssl_verify                | No           | Boolean  | SSL verification for 
requests to LLM service. Default: true                                  |
+
+## How it works
+
+![image](https://github.com/user-attachments/assets/c7288e4f-00fc-46ca-b69e-d3d74d7085ca)
+
+## Example usage
+
+Create a route with the `ai-request-rewrite` plugin like:
+
+```shell
+curl "http://127.0.0.1:9180/apisix/admin/routes/1"; -X PUT \
+  -H "X-API-KEY: ${ADMIN_API_KEY}" \

Review Comment:
   Replace `ADMIN_API_KEY` with `admin_key` in docs because apache/apisix docs 
use `admin_key` everywhere:
   
   <img width="828" alt="image" 
src="https://github.com/user-attachments/assets/4a2eb113-1bd1-4468-915c-c82a48666cf9";
 />
   



-- 
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-unsubscr...@apisix.apache.org

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

Reply via email to