The CREATE_AI_GATEWAY procedure is used to create a gateway configuration. An AI gateway sits between AI functions and the actual 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 automatically fuses and switches to other available endpoints if a particular endpoint fails consecutively. 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.2.1.
Syntax
PROCEDURE create_ai_gateway(
IN gateway_name VARCHAR(256),
IN json_params JSON);
Parameters
Parameter |
Description |
Type |
Value range |
Nullable |
|---|---|---|---|---|
| gateway_name | Gateway name. | 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:
Field |
Type |
Required |
Note |
|---|---|---|---|
endpoints |
JSON ARRAY | Yes | Route list. Each item is a JSON object and must contain the following fields: name, model, and weight. model is in the provider/model format. |
circuit_breaker |
JSON OBJECT | No | Circuit breaking configuration. It is used to automatically perform circuit breaking when an endpoint fails consecutively and route traffic to other available endpoints. |
The circuit_breaker field supports the following:
Field |
Type |
Note |
|---|---|---|
failure_rate_threshold |
INT | Failure rate threshold (in percentage). |
window_size_seconds |
INT | Statistical window size, in seconds. |
minimum_requests |
INT | The minimum number of requests that trigger a circuit breaker. |
break_duration_seconds |
INT | The circuit breaking duration, in seconds. |
probe_requests |
INT | Number of alive probe requests. |
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
}
}');