Skip to content

Latest commit

 

History

History
226 lines (150 loc) · 16.4 KB

File metadata and controls

226 lines (150 loc) · 16.4 KB

Policies

Overview

Available Operations

list

Returns a paginated list of policies for the current project.

Example Usage

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)

Parameters

Parameter Type Required Description
limit Optional[int] ➖ N/A
starting_after Optional[str] ➖ A cursor for use in pagination.
ending_before Optional[str] ➖ A cursor for use in pagination.
project_id Optional[str] ➖ Optional filter by project ID.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.PolicyListResponseBody

Errors

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

create

Creates a new router policy with model configuration, evaluators, retry settings, and limits.

Example Usage

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)

Parameters

Parameter Type Required Description Example
display_name str ✔️ N/A Production guardrails
description Optional[str] ➖ N/A
enabled Optional[bool] ➖ N/A
evaluators List[models.EvaluatorRef] ➖ N/A
limits Optional[models.Limits] ➖ N/A
models_config Optional[models.ModelsConfig] ➖ N/A
project_id Optional[str] ➖ Optional project ID. If null/omitted, the entity is global (workspace-wide).
retry_config Optional[models.PolicyRetryConfig] ➖ N/A
timeout Optional[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.PolicyCreateResponseBody

Errors

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

delete

Deletes an existing policy by ID.

Example Usage

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

Parameters

Parameter Type Required Description
policy_id str ✔️ The ID of the policy
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

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

retrieve

Retrieves the details of an existing policy by ID.

Example Usage

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)

Parameters

Parameter Type Required Description
policy_id str ✔️ The ID of the policy
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.PolicyGetResponseBody

Errors

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

update

Partially updates an existing policy. Only provided fields are updated.

Example Usage

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)

Parameters

Parameter Type Required Description
policy_id str ✔️ The ID of the policy
description Optional[str] ➖ N/A
display_name Optional[str] ➖ N/A
enabled Optional[bool] ➖ N/A
evaluators List[models.EvaluatorRef] ➖ N/A
limits Optional[models.Limits] ➖ N/A
models_config Optional[models.ModelsConfig] ➖ N/A
project_id Optional[str] ➖ Optional project ID to assign the policy to.
retry_config Optional[models.PolicyRetryConfig] ➖ N/A
timeout Optional[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.PolicyUpdateResponseBody

Errors

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