curl --request POST \
--url https://api.edenai.run/v3/manage/guardrails/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "",
"model_rules": null,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_alert_percent": 50
}
'import requests
url = "https://api.edenai.run/v3/manage/guardrails/"
payload = {
"name": "<string>",
"description": "",
"model_rules": None,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_alert_percent": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '',
model_rules: null,
rate_limit: '<string>',
budget_cap: 0,
budget_alert_percent: 50
})
};
fetch('https://api.edenai.run/v3/manage/guardrails/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.edenai.run/v3/manage/guardrails/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '',
'model_rules' => null,
'rate_limit' => '<string>',
'budget_cap' => 0,
'budget_alert_percent' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.edenai.run/v3/manage/guardrails/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.edenai.run/v3/manage/guardrails/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.edenai.run/v3/manage/guardrails/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"is_active": true,
"is_default": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"model_rules": null,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_period": "daily",
"budget_alert_percent": 50
}Create a guardrail
Creates a guardrail. It starts active and applies to nothing until it is assigned to a key, a member, a role, or made the organization default. Names are unique within the organization (400). model_rules is {"default": "allow" | "deny", "rules": [{"pattern", "action"}]}: a pattern is a model (openai/gpt-4o), a whole provider (openai/*) or a Universal AI id (audio/tts/google), and action is allow or deny. rate_limit is N/second, N/minute, N/hour or N/day, within the plan’s own limit. budget_cap and budget_period (daily, weekly, monthly) go together; budget_alert_percent (1 to 100) needs them. Requires the manage:write scope.
curl --request POST \
--url https://api.edenai.run/v3/manage/guardrails/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "",
"model_rules": null,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_alert_percent": 50
}
'import requests
url = "https://api.edenai.run/v3/manage/guardrails/"
payload = {
"name": "<string>",
"description": "",
"model_rules": None,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_alert_percent": 50
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '',
model_rules: null,
rate_limit: '<string>',
budget_cap: 0,
budget_alert_percent: 50
})
};
fetch('https://api.edenai.run/v3/manage/guardrails/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.edenai.run/v3/manage/guardrails/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '',
'model_rules' => null,
'rate_limit' => '<string>',
'budget_cap' => 0,
'budget_alert_percent' => 50
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.edenai.run/v3/manage/guardrails/"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.edenai.run/v3/manage/guardrails/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.edenai.run/v3/manage/guardrails/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"\",\n \"model_rules\": null,\n \"rate_limit\": \"<string>\",\n \"budget_cap\": 0,\n \"budget_alert_percent\": 50\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"is_active": true,
"is_default": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"description": "<string>",
"model_rules": null,
"rate_limit": "<string>",
"budget_cap": 0,
"budget_period": "daily",
"budget_alert_percent": 50
}Authorizations
Body
A guardrail's settings. Every field but name is optional and left out means not set: no
model rules, no rate limit, no budget. A new guardrail starts active; pause it with
PUT /v3/manage/guardrails/{guardrail_id}/active.