Current Behavior
The ai-request-rewrite plugin returns the LLM output directly as the HTTP response instead of forwarding the modified request body to the configured upstream server.
Reference: https://apisix.apache.org/docs/apisix/plugins/ai-request-rewrite/
Expected Behavior
The plugin should forward the LLM-modified request body to the upstream server and return the upstream's response, not return the LLM output directly.
Error Logs
No error logs. The plugin executes successfully but returns the wrong response.
Steps to Reproduce
- Create a route with ai-request-rewrite plugin and upstream:
curl -X PUT "http://localhost:9180/apisix/admin/routes/test"
-H "X-API-KEY: ${admin_key}"
-d '{
"id": "test",
"uri": "/test",
"upstream": {"type": "roundrobin", "nodes": [{"host": "httpbin.org", "port": 80, "weight": 1}]},
"plugins": {
"ai-request-rewrite": {
"prompt": "Add a field processed:true to the JSON. Return the modified JSON only.",
"provider": "openai-compatible",
"auth": {"header": {"Authorization": "Bearer xxxxxxxxxx"}},
"options": {"model": "MiniMax-M2.7-highspeed"},
"override": {"endpoint": "https://aix.xxxxxxxxx.com/v1/chat/completions"}
}
}
}'
- Send a request:
curl -X POST "http://localhost:9080/test" -H "Content-Type: application/json" -d '{"name":"John"}'
Actual Response: {"data":"{"name":"John","processed":true}"}
Expected Response: The upstream's response, not the LLM output directly.
Environment
- APISIX version: 3.16
- Plugin: ai-request-rewrite
- LLM Provider: openai-compatible (MiniMax-M2.7-highspeed)
Current Behavior
The ai-request-rewrite plugin returns the LLM output directly as the HTTP response instead of forwarding the modified request body to the configured upstream server.
Reference: https://apisix.apache.org/docs/apisix/plugins/ai-request-rewrite/
Expected Behavior
The plugin should forward the LLM-modified request body to the upstream server and return the upstream's response, not return the LLM output directly.
Error Logs
No error logs. The plugin executes successfully but returns the wrong response.
Steps to Reproduce
curl -X PUT "http://localhost:9180/apisix/admin/routes/test"
-H "X-API-KEY: ${admin_key}"
-d '{
"id": "test",
"uri": "/test",
"upstream": {"type": "roundrobin", "nodes": [{"host": "httpbin.org", "port": 80, "weight": 1}]},
"plugins": {
"ai-request-rewrite": {
"prompt": "Add a field processed:true to the JSON. Return the modified JSON only.",
"provider": "openai-compatible",
"auth": {"header": {"Authorization": "Bearer xxxxxxxxxx"}},
"options": {"model": "MiniMax-M2.7-highspeed"},
"override": {"endpoint": "https://aix.xxxxxxxxx.com/v1/chat/completions"}
}
}
}'
curl -X POST "http://localhost:9080/test" -H "Content-Type: application/json" -d '{"name":"John"}'
Actual Response: {"data":"{"name":"John","processed":true}"}
Expected Response: The upstream's response, not the LLM output directly.
Environment