The CREATE_AI_GATEWAY procedure is used to create a gateway configuration. The AI gateway sits between the AI function and the real model service, providing routing and disaster recovery capabilities: it unifies management of multiple endpoints under the same logical model (which can correspond to different keys, vendors, or models), distributes traffic to healthy nodes based on weights; and if an endpoint fails continuously, it automatically fuses and switches to another available endpoint. Endpoints do not carry an access_key; credentials are uniformly provided by the vendor's configuration.
Note
This process is supported starting from V4.6.0 BP1.
Syntax
PROCEDURE create_ai_gateway(
IN gateway_name VARCHAR(256),
IN json_params JSON);
Parameters
Parameter |
Description |
Type |
Value range |
Nullable |
|---|---|---|---|---|
| gateway_name | The name of the gateway. | VARCHAR(256) | Up to 256 bytes | NO |
| json_params | Gateway configuration, which must be a JSON object. | JSON | See the following table. | NO |
The json_params top-level fields are as follows:
Column |
Type |
Required |
Note |
|---|---|---|---|
endpoints |
JSON ARRAY | Yes | Route list. Each item is a JSON object and must contain the following fields:name、model、weightfield.modelisprovider/modelFormat. |
circuit_breaker |
JSON OBJECT | No | Circuit breaking configuration. It is used to automatically perform circuit breaking when an endpoint fails continuously and route traffic to other available endpoints. |
The circuit_breaker field supports the following:
Column |
Type |
Note |
|---|---|---|
failure_rate_threshold |
INT | Failure rate threshold (in percentage). |
window_size_seconds |
INT | Statistics window size (seconds). |
minimum_requests |
INT | The minimum number of requests that trigger a circuit breaker. |
break_duration_seconds |
INT | The circuit breaker duration, in seconds. |
probe_requests |
INT | Number of alive probes. |
Examples
CALL DBMS_AI_SERVICE.CREATE_AI_GATEWAY('prod_gateway', '{
"endpoints": [
{"name":"ep1","model":"aliyun/qwen-plus","weight":70},
{"name":"ep2","model":"deepseek/deepseek-chat","weight":30}
],
"circuit_breaker": {
"failure_rate_threshold": 50,
"window_size_seconds": 60,
"minimum_requests": 10,
"break_duration_seconds": 60,
"probe_requests": 3
}
}');
