Skip to main content

RoutingRules

List RoutingRules

Returns a paginated list of routing rules for the current project, ordered by priority ascending.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.routing_rules.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.routingRules.list({});

  console.log(result);
}

run();

Create a RoutingRule

Creates a new routing rule with expression, models configuration, and priority settings.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.routing_rules.create(display_name="Freeda_Beahan")

    # 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.routingRules.create({
    displayName: "Freeda_Beahan",
  });

  console.log(result);
}

run();

List Used Models

Returns the distinct model refs referenced across all routing rules in scope.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.routing_rules.list_used_models()

    # 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.routingRules.listUsedModels();

  console.log(result);
}

run();

Delete a RoutingRule

Deletes an existing routing rule by ID.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.routing_rules.delete(routing_rule_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.routingRules.delete({
    routingRuleId: "<id>",
  });

}

run();

Retrieve a RoutingRule

Retrieves the details of an existing routing rule by ID.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.routing_rules.retrieve(routing_rule_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.routingRules.retrieve({
    routingRuleId: "<id>",
  });

  console.log(result);
}

run();

Update a RoutingRule

Partially updates an existing routing rule. 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.routing_rules.update(routing_rule_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.routingRules.update({
    routingRuleId: "<id>",
    requestBody: {},
  });

  console.log(result);
}

run();