Minimal Model Endpoint

Create a small model, run it locally, run it ephemerally, and deploy it as an endpoint.

Create a_plus_2b_model.py:

import rebase as rb


class APlus2BPredictor(rb.Predictor):
    name = "a-plus-2b"
    project = "mini-models"
    endpoint = rb.endpoint(path="/a-plus-2b", auth="workspace")

    def predict(self, a: float = 0, b: float = 0) -> dict:
        return {"prediction": a + 2 * b}


model = APlus2BPredictor()


if __name__ == "__main__":
    print(model.predict(a=1, b=3))

Run it locally:

python a_plus_2b_model.py

Expected output:

{'prediction': 7}

Run the same model as an ephemeral cloud run:

rebase run a_plus_2b_model.py --param a=1 --param b=3

Deploy it as a persistent model endpoint:

rebase deploy a_plus_2b_model.py

Invoke the endpoint:

rebase endpoint invoke mini-models/a-plus-2b --json '{"a": 1, "b": 3}'

For agent or service access, change the endpoint to auth="api_key" and invoke it with a Rebase API key.