Yilialinn commented on code in PR #13210: URL: https://github.com/apache/apisix/pull/13210#discussion_r3108758547
########## docs/en/latest/plugins/ai-request-rewrite.md: ########## @@ -27,70 +27,83 @@ description: The ai-request-rewrite plugin intercepts client requests before the # --> +<head> + <link rel="canonical" href="https://docs.api7.ai/hub/ai-request-rewrite" /> +</head> + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ## 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. +The `ai-request-rewrite` Plugin processes client requests by forwarding them to LLM services for transformation before relaying them to Upstream services. This enables LLM-powered modifications such as data redaction, content enrichment, or reformatting. The Plugin supports integration with OpenAI, DeepSeek, Gemini, Vertex AI, Anthropic, OpenRouter, and other OpenAI-compatible APIs. ## 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, azure-openai, aimlapi, anthropic, openrouter, gemini, vertex-ai, and openai-compatible. When `aimlapi` is selected, the plugin uses the OpenAI-compatible driver with a default endpoint of `https://api.aimlapi.com/v1/chat/completions`. | -| provider_conf | No | Object | Configuration for the specific provider. Required when `provider` is set to `vertex-ai` and `override` is not configured. | -| provider_conf.project_id | Yes | String | Google Cloud Project ID. | -| provider_conf.region | Yes | String | Google Cloud Region. | -| 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._-]+$`. | -| auth.gcp | No | Object | Configuration for Google Cloud Platform (GCP) authentication. | -| auth.gcp.service_account_json | No | String | Content of the GCP service account JSON file. This can also be configured by setting the `GCP_SERVICE_ACCOUNT` environment variable. | -| auth.gcp.max_ttl | No | Integer | Maximum TTL (in seconds) for caching the GCP access token. Minimum: 1. | -| auth.gcp.expire_early_secs| No | Integer | Seconds to expire the access token before its actual expiration time to avoid edge cases. Minimum: 0. Default: 60. | -| 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 or aimlapi services | -| override.endpoint | No | String | Override the default endpoint when using OpenAI-compatible services (e.g., self-hosted models or third-party LLM services). When the provider is 'openai-compatible', the endpoint field is required. | -| timeout | No | Integer | Total timeout in milliseconds for requests to LLM service, including connect, send, and read timeouts. Range: 1 - 60000. Default: 30000| -| 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 - - Review Comment: Unsupported yet. I've added the images -- 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]
