Skip to content
Docs

Create rule

POSThttps://api.vercel.com/ai-gateway/rules
Create a routing rule
https://api.vercel.com/ai-gateway/rules
const response = await fetch('https://api.vercel.com/ai-gateway/rules?teamId=string&slug=string', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"type": "rewrite",
"match": {
"model": "string"
},
"action": {
"rewriteModel": "string",
"reason": "Customer requested refund"
},
"enabled": "true",
"description": "string"
}),
});
const data = await response.json();
console.log(data);
Response
{
"action": {
"reason": "Customer requested refund",
"rewriteModel": "string"
},
"createdAt": "123",
"createdBy": "string",
"deleted": "false",
"description": "string",
"enabled": "false",
"match": {
"model": "string"
},
"ownerId": "example_id",
"ruleId": "example_id",
"type": "deny",
"updatedAt": "123",
"updatedBy": "string"
}
AuthorizationbearerToken

Default authentication mechanism

teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
typestringRequired
rewrite sends requests for the matched model to another model. deny rejects them.
matchobjectRequired
actionobjectOptional
Required when type is rewrite.
enabledbooleanOptional
Whether the rule is enabled. Defaults to true.
descriptionstringOptional
A free-text note about the rule.
201Success
actionobjectOptional
createdAtnumberRequired
createdBystringOptional
deletedbooleanOptional
descriptionstringOptional
enabledbooleanRequired
matchobjectOptional
ownerIdstringRequired
ruleIdstringRequired
typestringRequired
updatedAtnumberRequired
updatedBystringOptional
400One of the provided values in the request body is invalid.
401The request is not authorized.
403You do not have permission to access this resource.
404Error
409Error
410Error
500Error