Skip to content

pixano_inference.api.v1.inference

/v1 synchronous inference routes, registered from the capability table.

Each capability gets POST /inference/<name> (JSON body) and, when it accepts raw uploads, POST /inference/<name>/binary (multipart). The request and response models, the upload fields and the capability name all come from :data:pixano_inference.models.capabilities.CAPABILITIES.

build_inference_router(deployment_manager)

Build the /inference router bound to deployment_manager.

Source code in pixano_inference/api/v1/inference.py
def build_inference_router(deployment_manager: DeploymentManager) -> APIRouter:
    """Build the `/inference` router bound to *deployment_manager*."""
    router = APIRouter(prefix="/inference", tags=["inference"])

    # The route name is part of the published OpenAPI document (operationId and summary).
    for spec in CAPABILITIES:
        router.add_api_route(
            f"/{spec.name}",
            _json_endpoint(deployment_manager, spec),
            methods=["POST"],
            response_model=spec.response_type,
            name=spec.name,
        )
        if spec.binary is not None:
            router.add_api_route(
                f"/{spec.name}/binary",
                _binary_endpoint(deployment_manager, spec),
                methods=["POST"],
                response_model=spec.response_type,
                name=f"{spec.name}_binary",
            )

    return router