SDK reference for the Smart Routers API, available in Node.js and Python.
Smart Routers
List Smart Routers
Lists Smart Routers in the current workspace, ordered newest first. Use cursor pagination and optional key, profile, or enabled-state filters to narrow the results.
from orq_ai_sdk import Orqimport oswith Orq( api_key=os.getenv("ORQ_API_KEY"),) as orq: res = orq.smart_routers.list() # 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.smartRouters.list(); console.log(result);}run();
Creates a Smart Router in the current workspace from 2 to 50 distinct eligible models. The key must be unique in the workspace and becomes part of the model reference used in AI Gateway requests.
from orq_ai_sdk import Orqimport oswith Orq( api_key=os.getenv("ORQ_API_KEY"),) as orq: res = orq.smart_routers.create(key="<key>", models=[ "<value 1>", "<value 2>", "<value 3>", ], profile="SMART_ROUTER_PROFILE_QUALITY") # 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.smartRouters.create({ key: "<key>", models: [ "<value 1>", "<value 2>", "<value 3>", ], profile: "SMART_ROUTER_PROFILE_QUALITY", }); console.log(result);}run();
Permanently deletes a Smart Router and removes its AI Gateway model configuration. A Smart Router referenced by an experiment cannot be deleted.
from orq_ai_sdk import Orqimport oswith Orq( api_key=os.getenv("ORQ_API_KEY"),) as orq: res = orq.smart_routers.delete(smart_router_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.smartRouters.delete({ smartRouterId: "<id>", }); console.log(result);}run();
Show Parameters
{ "smart_router_id": str, # required}
{ smartRouterId: string; // required}
Update a Smart Router
Updates the model pool, routing profile, session affinity, or any combination. Omitted fields retain their current values. The router key and model reference cannot be changed.
from orq_ai_sdk import Orqimport oswith Orq( api_key=os.getenv("ORQ_API_KEY"),) as orq: res = orq.smart_routers.update(smart_router_id="<id>", models=["<value>"]) # 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.smartRouters.update({ models: ["<value>"], }, "<id>"); console.log(result);}run();