rebase.endpoint

Declare an HTTP endpoint for a function, workflow, or model.

Signature

rb.endpoint(
    *,
    name: str | None = None,
    method: str = "POST",
    path: str | None = None,
    auth: str = "api_key",
    mode: str | None = None,
    timeout: int | None = None,
    timeout_seconds: int | None = None,
    docs: bool = False,
    enabled: bool = True,
) -> EndpointConfig

Parameters

ParameterTypeDescription
name`strNone`
methodstrHTTP method. Supported values are GET, POST, PUT, PATCH, and DELETE. Defaults to POST.
path`strNone`
authstrInvocation auth mode. Supported values are api_key, workspace, and public. Defaults to api_key.
mode`strNone`
timeout`intNone`
timeout_seconds`intNone`
docsboolStore endpoint documentation metadata for future docs generation.
enabledboolWhether the endpoint can be invoked.

Usage

import rebase as rb

project = rb.project("forecasting")


@project.function(endpoint=rb.endpoint(method="POST", path="/forecast"))
def forecast(zone: str = "SE3") -> dict:
    return {"zone": zone}

Standalone decorators are supported. Without project, the target belongs to the implicit default project.

@rb.function(project="forecasting")
@rb.endpoint(method="POST", path="/forecast")
def forecast(zone: str = "SE3") -> dict:
    return {"zone": zone}

Models accept endpoint configs at construction time:

model = PricePredictor(
    project="forecasting",
    endpoint=rb.endpoint(method="POST", path="/predict"),
)

On this page