Skip to main content

enterprise_ai.llm.routing

Source: sdks/python/src/enterprise_ai/llm/routing/__init__.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class RoutesClient​

/v1/routes.

Resource

RoutesClient.create​

create(route: dict[str, Any]) -> Any

Create a routing rule. Creates a routing rule of the tenant and answers 201. A platform principal without tenant answers 403 platform_only; an unknown strategy 422 parameter_invalid. Audited (route.create). Requires tenant_admin, platform_admin or ai_platform_engineer.

Route: /v1/routes (POST).

NameTypeDefaultRequiredDescription
routedict[str, Any]yesRoute document sent as the request body.

Returns: Any. Decoded JSON answer of the operation "Create a routing rule".

Raises: the typed errors of the transport (Errors).

RoutesClient.delete​

delete(route_id: str) -> Any

Delete a routing rule. Deletes a routing rule of the tenant and answers 204. Unknown rule: 404 route_not_found. Audited (route.delete). Requires tenant_admin, platform_admin or ai_platform_engineer.

Route: /v1/routes/{rid} (DELETE).

NameTypeDefaultRequiredDescription
route_idstryesIdentifier of the routing rule.

Returns: Any. Decoded JSON answer of the operation "Delete a routing rule".

Raises: the typed errors of the transport (Errors).

RoutesClient.list​

list(**page: Any) -> Any

List the routing rules. Routing rules of the tenant by priority then name, each with its match, strategy, candidates, fallbacks, constraints and target_model (the first candidate). Requires a reader role.

Route: /v1/routes (GET).

NameTypeDefaultRequiredDescription
**pageAnynoPagination options: limit (maximum number of routes per page) and cursor (cursor of the page to read).

Returns: Any. Decoded JSON answer of the operation "List the routing rules".

Raises: the typed errors of the transport (Errors).

RoutesClient.replace​

replace(route_id: str, route: dict[str, Any]) -> Any

Replace a routing rule. Replaces the match, strategy, candidates, fallbacks, constraints, priority and enabled flag of a rule of the tenant (omitted fields take their default; the name is kept). Unknown rule: 404 route_not_found. Audited (route.update). Requires tenant_admin, platform_admin or ai_platform_engineer.

Route: /v1/routes/{rid} (PUT).

NameTypeDefaultRequiredDescription
route_idstryesIdentifier of the routing rule.
routedict[str, Any]yesFull route document that replaces the current one.

Returns: Any. Decoded JSON answer of the operation "Replace a routing rule".

Raises: the typed errors of the transport (Errors).

RoutesClient.simulate​

simulate(model: str | None = None, task: str | None = None, data_classification: str | None = None, **extra: Any) -> Any

Simulate the routing of a request. Shows which model a request would be routed to, without calling it: the rule given by route_id or the first enabled rule that matches, the tenant allow and deny lists (narrowed by the request), the classification and the fallback policy. Answers the selected model, fallbacks, rejected candidates with their reason and the rule used; no eligible model answers 422 no_eligible_model. Restricted models are only allowed for tenant_admin and security_officer with allow_restricted. Requires a reader role.

Route: /v1/routes/simulate (POST).

NameTypeDefaultRequiredDescription
modelstr | NoneNonenoOnly cards whose model pattern matches this model id (case insensitive glob).
taskstr | NoneNonenoKind of task of the simulated call, used by the routing rules.
data_classificationstr | NoneNonenoClassification of the data of the simulated call, from public to secret.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Simulate the routing of a request".

Raises: the typed errors of the transport (Errors).

Functions​

classification_allows​

classification_allows(model_max: str, data: str) -> bool

True when a model cleared for model_max may process data classified data.

NameTypeDefaultRequiredDescription
model_maxstryesHighest classification the model is cleared for, on the same scale.
datastryesClassification of the data: public, internal, confidential, restricted or secret.

Returns: bool. True when data is not above model_max.

eligible_models​

eligible_models(models: Iterable[dict[str, Any]], data_classification: str = 'internal', region: str | None = None, capability: str | None = None) -> list[dict[str, Any]]

Filter registry entries locally: approved, cleared for the data, in region, with capability.

NameTypeDefaultRequiredDescription
modelsIterable[dict[str, Any]]yesRegistry entries or Model Manifests to filter.
data_classificationstr'internal'noClassification of the data to process (default internal), compared with data_classification_max.
regionstr | NoneNonenoRegion the model must serve when it declares data_residency.regions; no filter when omitted.
capabilitystr | NoneNonenoCapability the model must list in capabilities; no filter when omitted.

Returns: list[dict[str, Any]]. Entries whose status is approved or restricted and that pass every filter, in input order.

fallback_chain​

fallback_chain(model: dict[str, Any]) -> list[str]

Primary model id followed by its declared fallbacks.

NameTypeDefaultRequiredDescription
modeldict[str, Any]yesRegistry entry or Model Manifest with model_id and fallbacks.

Returns: list[str]. List of model identifiers: the primary one first, then the fallbacks in order.