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


##########
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

Review Comment:
   ```suggestion
   ## Examples
   
   The examples below demonstrate how you can configure `ai-request-rewrite` 
for different scenarios.
   
   :::note
   
   You can fetch the admin_key from config.yaml and save to an environment 
variable with the following command:
   
   admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 
's/"//g')
   
   :::
   
   ### Redact sensitive information
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to