public static String extractJsonBodyFromHttpResponse(final String aiResponse) {
        if (Objects.isNull(aiResponse) || aiResponse.isEmpty()) {
            return null;
        }

        String[] lines = aiResponse.split("\\R");

        int emptyLineIndex = -1;
        for (int i = 0; i < lines.length; i++) {
            if (lines[i].trim().isEmpty()) {
                emptyLineIndex = i;
                break;
            }
        }

        if (emptyLineIndex == -1 || emptyLineIndex == lines.length - 1) {
            return null;
        }

        StringBuilder bodyBuilder = new StringBuilder();
        for (int i = emptyLineIndex + 1; i < lines.length; i++) {
            bodyBuilder.append(lines[i]);
            bodyBuilder.append("\n");
        }

        String body = bodyBuilder.toString().trim();

        if (body.startsWith("{") && body.endsWith("}") || body.startsWith("[") && body.endsWith("]")) {
            Map<String, Object> requestBodyMap = GsonUtils.getInstance().convertToMap(body);
            return GsonUtils.getInstance().toJson(requestBodyMap);
        }

        return null;
    }
this is ai request transformer plugin.
shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-request-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/request/AiRequestTransformerPlugin.java