rules
Creates, updates, deletes, gets or lists a rules resource.
Overview
| Name | rules |
| Type | Resource |
| Id | vercel.ai_gateway.rules |
Fields
The following fields are returned by SELECT queries:
- list
Public response shape for AI Gateway routing rules. Used so OpenAPI generation can avoid ElectroDB's recursive EntityItem types.
| Name | Datatype | Description |
|---|---|---|
owner_id | string | (wire: ownerId) |
rule_id | string | (wire: ruleId) |
action | object | |
created_at | number | (wire: createdAt) |
created_by | string | (wire: createdBy) |
deleted | boolean | (false, true) |
description | string | |
enabled | boolean | (false, true) |
match | object | |
type | string | (deny, rewrite) |
updated_at | number | (wire: updatedAt) |
updated_by | string | (wire: updatedBy) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | include_disabled, team_id, slug | List the authenticated team's routing rules | |
create | insert | team_id, slug | Create a routing rule | |
update | update | team_id, slug | Update a routing rule (enabled, action, or description) | |
delete | delete | rule_id | team_id, slug | Delete a routing rule (soft delete) |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
rule_id | string | (wire: ruleId) |
include_disabled | string | (wire: includeDisabled) |
slug | string | The Team slug to perform the request on behalf of. |
team_id | string | The Team identifier to perform the request on behalf of. (wire: teamId) |
SELECT examples
- list
List the authenticated team's routing rules
SELECT
owner_id,
rule_id,
action,
created_at,
created_by,
deleted,
description,
enabled,
match,
type,
updated_at,
updated_by
FROM vercel.ai_gateway.rules
WHERE include_disabled = '{{ include_disabled }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;
INSERT examples
- create
- Manifest
Create a routing rule
INSERT INTO vercel.ai_gateway.rules (
team_id,
slug
)
SELECT
'{{ team_id }}',
'{{ slug }}'
RETURNING
owner_id,
rule_id,
action,
created_at,
created_by,
deleted,
description,
enabled,
match,
type,
updated_at,
updated_by
;
# Description fields are for documentation purposes
- name: rules
props:
- name: team_id
value: "{{ team_id }}"
description: The Team identifier to perform the request on behalf of.
description: The Team identifier to perform the request on behalf of.
- name: slug
value: "{{ slug }}"
description: The Team slug to perform the request on behalf of.
description: The Team slug to perform the request on behalf of.
UPDATE examples
- update
Update a routing rule (enabled, action, or description)
UPDATE vercel.ai_gateway.rules
SET
-- No updatable properties
WHERE
team_id = '{{ team_id}}'
AND slug = '{{ slug}}'
RETURNING
owner_id,
rule_id,
action,
created_at,
created_by,
deleted,
description,
enabled,
match,
type,
updated_at,
updated_by;
DELETE examples
- delete
Delete a routing rule (soft delete)
DELETE FROM vercel.ai_gateway.rules
WHERE rule_id = '{{ rule_id }}' --required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;