> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart Routers SDK Reference

> 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

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

      res = orq.smart_routers.list()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "limit": Optional[int],
        "starting_after": Optional[str],
        "ending_before": Optional[str],
        "search": Optional[str],
        "profile": List[Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"]],  # optional
        "enabled": Optional[bool],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      limit?: number;
      startingAfter?: string;
      endingBefore?: string;
      search?: string;
      profile?: ("SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST")[];
      enabled?: boolean;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "object": str,
        "data": [{
            "smart_router_id": str,
            "key": str,
            "model_ref": str,
            "models": List[str],
            "profile": Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"],
            "enabled": bool,
            "created_at": date,
            "updated_at": date,
        }],
        "has_more": bool,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      object: string;
      data: {
        smartRouterId: string;
        key: string;
        modelRef: string;
        models: string[];
        profile: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";
        enabled: boolean;
        createdAt: Date;
        updatedAt: Date;
      }[];
      hasMore: boolean;
    }
    ```
  </CodeGroup>
</Expandable>

### Create a Smart Router

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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with 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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "key": str,  # required
        "models": List[str],  # required
        "profile": Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"],  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      key: string;  // required
      models: string[];  // required
      profile: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router": {
            "smart_router_id": str,
            "key": str,
            "model_ref": str,
            "models": List[str],
            "profile": Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"],
            "enabled": bool,
            "created_at": date,
            "updated_at": date,
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouter: {
        smartRouterId: string;
        key: string;
        modelRef: string;
        models: string[];
        profile: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";
        enabled: boolean;
        createdAt: Date;
        updatedAt: Date;
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve a Smart Router

Retrieves a Smart Router by ID from the current workspace, including its model reference, model pool, routing profile, and enabled state.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

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

      res = orq.smart_routers.get(smart_router_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.smartRouters.get({
      smartRouterId: "<id>",
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouterId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router": {
            "smart_router_id": str,
            "key": str,
            "model_ref": str,
            "models": List[str],
            "profile": Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"],
            "enabled": bool,
            "created_at": date,
            "updated_at": date,
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouter: {
        smartRouterId: string;
        key: string;
        modelRef: string;
        models: string[];
        profile: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";
        enabled: boolean;
        createdAt: Date;
        updatedAt: Date;
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Delete a Smart Router

Permanently deletes a Smart Router and removes its AI Gateway model configuration. A Smart Router referenced by an experiment cannot be deleted.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

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

      res = orq.smart_routers.delete(smart_router_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouterId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

### Update a Smart Router

Updates the model pool, routing profile, or both. Omitted fields retain their current values. The router key and model reference cannot be changed.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

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

      res = orq.smart_routers.update(smart_router_id="<id>")

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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({ smartRouterId: "<id>" });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router_id": str,  # required
        "models": List[str],  # optional
        "profile": Optional[Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"]],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouterId: string;  // required
      models?: string[];
      profile?: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "smart_router": {
            "smart_router_id": str,
            "key": str,
            "model_ref": str,
            "models": List[str],
            "profile": Literal["SMART_ROUTER_PROFILE_UNSPECIFIED", "SMART_ROUTER_PROFILE_QUALITY", "SMART_ROUTER_PROFILE_BALANCED", "SMART_ROUTER_PROFILE_COST"],
            "enabled": bool,
            "created_at": date,
            "updated_at": date,
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      smartRouter: {
        smartRouterId: string;
        key: string;
        modelRef: string;
        models: string[];
        profile: "SMART_ROUTER_PROFILE_UNSPECIFIED" | "SMART_ROUTER_PROFILE_QUALITY" | "SMART_ROUTER_PROFILE_BALANCED" | "SMART_ROUTER_PROFILE_COST";
        enabled: boolean;
        createdAt: Date;
        updatedAt: Date;
      };
    }
    ```
  </CodeGroup>
</Expandable>
