AI Gateway lets you add policies and configure plug-ins for Agent APIs to improve their security, performance, and maintainability.
Procedure
Go to the Instance page in the AI Gateway console and select the region where your instance is located.
On the target instance page, click Agent API. In the Agent API list, click the name of the target API to open its details page.
Select the Policies and Plug-ins tab and click Enable Policy/Plug-in.
In the Enable Policy/Plug-in panel, select Policy or Plugin.
Policy configuration
Concurrency control
Concurrency control rules count the total number of requests being processed by the gateway. When this number reaches a specified threshold, the gateway immediately blocks traffic. You can set this threshold to the maximum number of concurrent requests that your backend service can handle. This protects the availability of your backend service during periods of high concurrency.
Traffic shaping
Traffic shaping rules monitor the queries per second (QPS) of an API. When the QPS reaches a specified threshold, the gateway immediately blocks traffic. This prevents sudden traffic spikes from overwhelming the backend service and ensures high availability.
Circuit breaking policy
Circuit breaking rules monitor the response time or error rate of an API. When a threshold is reached, the gateway immediately trips the circuit. For a specified period, the gateway stops calling the unstable resource. This prevents the backend service from being affected and ensures its high availability. After the specified time, the gateway resumes calls to the resource.
IP blacklist and whitelist policy
The IP blacklist and whitelist policy controls client access to services based on a pre-configured list of allowed (whitelist) or denied (blacklist) IP addresses.
Timeout policy
AI Gateway provides API-level timeout settings. You can configure the maximum time the gateway waits for a response from a backend service for a specific API. If the gateway does not receive a response from the backend service within the specified time, it returns an HTTP status code of 504 (Gateway Timeout) to the client.
Retry policy
AI Gateway provides API-level retry settings that allow you to automatically retry failed requests. You can configure the conditions that trigger a retry, such as a connection failure, an unavailable backend service, or a specific HTTP status code.
Header modification policy
The header modification feature lets you modify the headers in the original request before it is forwarded to the backend service, or in the response from the backend service before it is returned to the client.
Plug-in configuration
Click the Add Plug-in tab.
In the Quick Navigation section, select a plug-in type or search for a plug-in by name, and then click the card for the desired plug-in:
If the plug-in is not installed, click Install and Configure in the pop-up window. Then, configure the plug-in rules and enable it.
If the plug-in is already installed, configure its rules and enable it in the pop-up window.
Click OK. You are returned to the More Policies and Plug-ins page, where you can view the attachment and enabled status of the plug-in for the API.