Skip to content

Latest commit

 

History

History
224 lines (146 loc) · 14.8 KB

File metadata and controls

224 lines (146 loc) · 14.8 KB

SmartRouters

Overview

Available Operations

  • list - List Smart Routers
  • create - Create a Smart Router
  • get - Retrieve a Smart Router
  • delete - Delete a Smart Router
  • update - Update a Smart Router

list

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.

Example Usage

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)

Parameters

Parameter Type Required Description
limit Optional[int] ➖ N/A
starting_after Optional[str] ➖ N/A
ending_before Optional[str] ➖ N/A
search Optional[str] ➖ N/A
profile List[models.SmartRouterProfile] ➖ N/A
enabled Optional[bool] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListSmartRoutersResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

create

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.

Example Usage

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)

Parameters

Parameter Type Required Description
key str ✔️ Unique key for the Smart Router within the workspace. Use lowercase letters, numbers, and hyphens.
models List[str] ✔️ Pool of 2 to 50 distinct eligible models. Each value uses provider/model format.
profile models.SmartRouterProfile ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.CreateSmartRouterResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

get

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

Example Usage

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)

Parameters

Parameter Type Required Description
smart_router_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetSmartRouterResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

delete

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

Example Usage

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)

Parameters

Parameter Type Required Description
smart_router_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.DeleteSmartRouterResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

update

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

Example Usage

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)

Parameters

Parameter Type Required Description
smart_router_id str ✔️ N/A
models List[str] ➖ Replacement pool of 2 to 50 distinct eligible models. Each value uses provider/model format. Omit to keep the current pool.
profile Optional[models.SmartRouterProfile] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.UpdateSmartRouterResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*