All Products
Search
Document Center

API Gateway:AI request/response transformation

Last Updated:Jun 17, 2026

Use a large language model (LLM) to modify request and response headers and bodies.

Runtime properties

Plugin execution phase: Authentication phase. Plugin execution priority: 410.

Configuration description

Name

Data type

Required

Default value

Description

request.enable

bool

Required

-

Specifies whether to enable request-phase transformation.

request.prompt

string

Required

-

The prompt that the LLM uses to transform the request.

response.enable

string

Required

-

Specifies whether to enable response-phase transformation.

response.prompt

string

Required

-

The prompt that the LLM uses to transform the response.

provider.serviceName

string

Required

-

The DNS-type service name. Currently, only Qwen is supported.

provider.domain

string

Required

-

The domain of the LLM service.

provider.apiKey

string

Required

-

The API key of the Alibaba Cloud DashScope service.

Configuration example

request:
    enable: false
    prompt: "If the request path starts with /httpbin, remove the /httpbin prefix. Do not change anything else."
response:
    enable: true
    prompt: "Modify the following HTTP response: 1. Change the content-type to application/json. 2. Convert the body from XML to JSON. 3. Remove the content-length."
provider:
    serviceName: qwen
    domain: dashscope.aliyuncs.com
    apiKey: xxxxxxxxxxxxx

Access the /xml endpoint of the original httpbin service. The response is as follows:

<?xml version='1.0' encoding='us-ascii'?>

<!--  A SAMPLE set of slides  -->

<slideshow
    title="Sample Slide Show"
    date="Date of publication"
    author="Yours Truly"
    >

    <!-- TITLE SLIDE -->
    <slide type="all">
      <title>Wake up to WonderWidgets!</title>
    </slide>

    <!-- OVERVIEW -->
    <slide type="all">
        <title>Overview</title>
        <item>Why WonderWidgets are great</item>
        <item/>
        <item>Who buys WonderWidgets</item>
    </slide>

</slideshow>

With the preceding configuration, access the /xml endpoint of the httpbin service through the gateway. The response is as follows:

{
  "slideshow": {
    "title": "Sample Slide Show",
    "date": "Date of publication",
    "author": "Yours Truly",
    "slides": [
      {
        "type": "all",
        "title": "Wake up to WonderWidgets!"
      },
      {
        "type": "all",
        "title": "Overview",
        "items": [
          "Why WonderWidgets are great",
          "",
          "Who buys WonderWidgets"
        ]
      }
    ]
  }
}