Policies
List Policies
Returns a paginated list of policies for the current project.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.policies.list(limit=10)
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.policies.list({});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
"project_id": Optional[str],
}
{
limit?: number;
startingAfter?: string;
endingBefore?: string;
projectId?: string;
}
Show Response
Show Response
{
"data": [{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float,
"currency": Literal["usd"],
"period": Literal["hour", "day", "week", "month"],
},
"requests": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
"tokens": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"],
"models": [{
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str,
"weight": Optional[float],
}],
},
"project_id": str,
"retry_config": { # optional
"count": int,
"on_codes": List[int], # optional
},
"slug": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}],
"has_more": bool,
"object": str,
}
{
data: {
id: string;
createdAt: Date;
createdById: string;
description?: string;
displayName: string;
enabled: boolean;
evaluators?: {
executeOn: "input" | "output" | "both";
id: string;
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number;
currency: "usd";
period: "hour" | "day" | "week" | "month";
};
requests?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
tokens?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin";
models: {
displayName?: string;
integrationId?: string;
model: string;
weight?: number;
}[];
};
projectId: string;
retryConfig?: {
count: number;
onCodes?: number[];
};
slug: string;
timeout: number;
updatedAt: Date;
updatedById: string;
}[];
hasMore: boolean;
object: string;
}
Create a Policy
Creates a new router policy with model configuration, evaluators, retry settings, and limits.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.policies.create(display_name="Zelda80")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.policies.create({
displayName: "Zelda80",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"display_name": str, # required
"description": Optional[str],
"enabled": Optional[bool],
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"], # required
"id": str, # required
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float, # required
"currency": Literal["usd"], # required
"period": Literal["hour", "day", "week", "month"], # required
},
"requests": { # optional
"amount": int, # required
"period": Literal["hour", "day", "week", "month"], # required
},
"tokens": { # optional
"amount": int, # required
"period": Literal["hour", "day", "week", "month"], # required
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"], # required
"models": [{ # required
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str, # required
"weight": Optional[float],
}],
},
"project_id": Optional[str],
"retry_config": { # optional
"count": int, # required
"on_codes": List[int], # optional
},
"timeout": Optional[int],
}
{
description?: string;
displayName: string; // required
enabled?: boolean;
evaluators?: {
executeOn: "input" | "output" | "both"; // required
id: string; // required
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number; // required
currency: "usd"; // required
period: "hour" | "day" | "week" | "month"; // required
};
requests?: {
amount: number; // required
period: "hour" | "day" | "week" | "month"; // required
};
tokens?: {
amount: number; // required
period: "hour" | "day" | "week" | "month"; // required
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin"; // required
models: { // required
displayName?: string;
integrationId?: string;
model: string; // required
weight?: number;
}[];
};
projectId?: string;
retryConfig?: {
count: number; // required
onCodes?: number[];
};
timeout?: number;
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float,
"currency": Literal["usd"],
"period": Literal["hour", "day", "week", "month"],
},
"requests": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
"tokens": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"],
"models": [{
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str,
"weight": Optional[float],
}],
},
"project_id": str,
"retry_config": { # optional
"count": int,
"on_codes": List[int], # optional
},
"slug": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}
{
id: string;
createdAt: Date;
createdById: string;
description?: string;
displayName: string;
enabled: boolean;
evaluators?: {
executeOn: "input" | "output" | "both";
id: string;
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number;
currency: "usd";
period: "hour" | "day" | "week" | "month";
};
requests?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
tokens?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin";
models: {
displayName?: string;
integrationId?: string;
model: string;
weight?: number;
}[];
};
projectId: string;
retryConfig?: {
count: number;
onCodes?: number[];
};
slug: string;
timeout: number;
updatedAt: Date;
updatedById: string;
}
Delete a Policy
Deletes an existing policy by ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.policies.delete(policy_id="<id>")
# Use the SDK ...
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
await orq.policies.delete({
policyId: "<id>",
});
}
run();
Show Parameters
Show Parameters
{
"policy_id": str, # required
}
{
policyId: string; // required
}
Retrieve a Policy
Retrieves the details of an existing policy by ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.policies.retrieve(policy_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.policies.retrieve({
policyId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"policy_id": str, # required
}
{
policyId: string; // required
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float,
"currency": Literal["usd"],
"period": Literal["hour", "day", "week", "month"],
},
"requests": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
"tokens": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"],
"models": [{
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str,
"weight": Optional[float],
}],
},
"project_id": str,
"retry_config": { # optional
"count": int,
"on_codes": List[int], # optional
},
"slug": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}
{
id: string;
createdAt: Date;
createdById: string;
description?: string;
displayName: string;
enabled: boolean;
evaluators?: {
executeOn: "input" | "output" | "both";
id: string;
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number;
currency: "usd";
period: "hour" | "day" | "week" | "month";
};
requests?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
tokens?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin";
models: {
displayName?: string;
integrationId?: string;
model: string;
weight?: number;
}[];
};
projectId: string;
retryConfig?: {
count: number;
onCodes?: number[];
};
slug: string;
timeout: number;
updatedAt: Date;
updatedById: string;
}
Update a Policy
Partially updates an existing policy. Only provided fields are updated.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.policies.update(policy_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.policies.update({
policyId: "<id>",
requestBody: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"policy_id": str, # required
"description": Optional[str],
"display_name": Optional[str],
"enabled": Optional[bool],
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"], # required
"id": str, # required
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float, # required
"currency": Literal["usd"], # required
"period": Literal["hour", "day", "week", "month"], # required
},
"requests": { # optional
"amount": int, # required
"period": Literal["hour", "day", "week", "month"], # required
},
"tokens": { # optional
"amount": int, # required
"period": Literal["hour", "day", "week", "month"], # required
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"], # required
"models": [{ # required
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str, # required
"weight": Optional[float],
}],
},
"project_id": Optional[str],
"retry_config": { # optional
"count": int, # required
"on_codes": List[int], # optional
},
"timeout": Optional[int],
}
{
policyId: string; // required
requestBody: { // required
description?: string;
displayName?: string;
enabled?: boolean;
evaluators?: {
executeOn: "input" | "output" | "both"; // required
id: string; // required
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number; // required
currency: "usd"; // required
period: "hour" | "day" | "week" | "month"; // required
};
requests?: {
amount: number; // required
period: "hour" | "day" | "week" | "month"; // required
};
tokens?: {
amount: number; // required
period: "hour" | "day" | "week" | "month"; // required
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin"; // required
models: { // required
displayName?: string;
integrationId?: string;
model: string; // required
weight?: number;
}[];
};
projectId?: string;
retryConfig?: {
count: number; // required
onCodes?: number[];
};
timeout?: number;
};
}
Show Response
Show Response
{
"id": str,
"created_at": date,
"created_by_id": str,
"description": Optional[str],
"display_name": str,
"enabled": bool,
"evaluators": [{ # optional
"execute_on": Literal["input", "output", "both"],
"id": str,
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
"timeout": Optional[int],
}],
"limits": { # optional
"budget": { # optional
"amount": float,
"currency": Literal["usd"],
"period": Literal["hour", "day", "week", "month"],
},
"requests": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
"tokens": { # optional
"amount": int,
"period": Literal["hour", "day", "week", "month"],
},
},
"models_config": { # optional
"mode": Literal["fallback", "latency_based", "weighted", "round_robin"],
"models": [{
"display_name": Optional[str],
"integration_id": Optional[str],
"model": str,
"weight": Optional[float],
}],
},
"project_id": str,
"retry_config": { # optional
"count": int,
"on_codes": List[int], # optional
},
"slug": str,
"timeout": int,
"updated_at": date,
"updated_by_id": str,
}
{
id: string;
createdAt: Date;
createdById: string;
description?: string;
displayName: string;
enabled: boolean;
evaluators?: {
executeOn: "input" | "output" | "both";
id: string;
isGuardrail?: boolean;
sampleRate?: number;
timeout?: number;
}[];
limits?: {
budget?: {
amount: number;
currency: "usd";
period: "hour" | "day" | "week" | "month";
};
requests?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
tokens?: {
amount: number;
period: "hour" | "day" | "week" | "month";
};
};
modelsConfig?: {
mode: "fallback" | "latency_based" | "weighted" | "round_robin";
models: {
displayName?: string;
integrationId?: string;
model: string;
weight?: number;
}[];
};
projectId: string;
retryConfig?: {
count: number;
onCodes?: number[];
};
slug: string;
timeout: number;
updatedAt: Date;
updatedById: string;
}