Skip to content

Serving a model, and taking it elsewhere

Call a model over HTTP from this machine, choose an alias or a pinned version, and pick the export that fits where the model has to run.

Applied ~11 min10 steps

You will be able to

  • Decide when a decision needs real-time scoring and when a batch will do
  • Create a local endpoint and call it with a bearer token
  • Keep the threshold decision separate from the score an endpoint returns
  • Choose an export for the place the model has to run

Read first

01

Does this decision need an answer now?

Predict

Predict first

You have two uses for a model: a list of likely churners that a team reviews every Monday, and a fraud check that has to answer before a payment completes. What does each one need?

Batch for bothBatch for the churn list, real time for the paymentReal time for both
Reveal

Batch for the list, real time for the payment. A serving endpointServing endpointA URL that takes rows and returns predictions immediately, for decisions that can't wait for a batch. is worth its extra moving parts only when the decision can't wait. Start from batch, and move to serving when you can name the decision that needs it.

02

The local server

Read

The app can serve registered models on your own machine, for scripts and apps that run there. It listens on 127.0.0.1 only, on port 8790 by default, and every scoring call needs a bearer token kept in your OS keychain.

RouteWhat it does
GET /v1/healthIs the server up? No token needed
GET /v1/modelsThe enabled endpoints and their input signatures
POST /v1/models/<name>:predictTakes rows, returns predictions

It isn't a production host. When other machines need the model, use an export.

03

Make an endpoint

In the app

Open a version's Monitor & serve tab and scroll to Serving.

  1. Press Start the server. It stays on at the next launch until you stop it.
  2. Press New endpoint, and choose what it serves and which scorer it uses.
  3. Press Try it. The request comes filled in with an example, and Send runs the same path as a real call.
  4. Press Copy curl to take the request to a terminal.

Rows sent to an endpoint go through the same signature check as a batch.

04

Alias or pinned?

Read

An endpoint can follow an alias or stay on one version. If it follows champion, promoting or rolling back changes what callers get, with no change on their side. A pinned version stays put, which suits a downstream system that has to validate each model first.

The scorer matters too. SQL answers in milliseconds, but only for linear models and single trees. The training engine handles any model, with a kernel run for each request.

05

A score isn't a decision

Explore

An endpoint returns predictions and class probabilities. What you do with them is a separate choice, and it's yours.

HExplorable · The ROC curve and its threshold

What does moving a threshold trade away, and what does the AUC really measure?

How often does a random positive score above a random negative?

0.75
How sure?
1.50
2.50
0.100
150
threshold

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Move the threshold, and watch what you trade. Then try a rare condition: the same model and the same AUC, but most flagged cases are now false alarms.

The right cut depends on how common the event is and what each mistake costs. Both can change while the model stays the same, so keep the threshold in the calling system, where you can change it.

06

Taking it elsewhere

Read

The Export tab packages a version for other places:

ExportUse it when
Native filesYou want the model, preprocessing and manifest as they are
ONNXYou need a language-neutral graph; the app checks it against native predictions and shows the largest difference
ONNX (torch)A neural network from Python or R must run without either
Python or R scoring scriptA scheduled job elsewhere will score tables
DuckDB SQLA linear model or single tree should run with no Python or R
MLflow modelYour team already serves models with MLflow

From Serving, you can also export a runnable FastAPI or plumber app with a Dockerfile. It returns predictions and probabilities only, without the SD, interval or set the local server can add.

07

Choose for your team

Reflect

Think about where a model of yours would have to run.

Who owns that system? Can it run Python or R? Does it need a person to approve each new version, or should it follow the champion?

Write down your answers before you pick an export. The choice usually depends more on who maintains it than on the model.

08

Check your understanding

Checkpoint

Check yourself

A colleague on another machine wants to call your local endpoint. What should you do?

Show the answer

Answer: b

The local server only accepts requests addressed to this machine, by design. Exports are how a model leaves it.

Check yourself

Your endpoint follows champion. You roll back by pointing champion at the previous version. What must callers change?

Show the answer

Answer: a

Callers use the endpoint's name. The alias decides which version answers, so moving it is the whole rollback.

Check yourself

Fraud becomes twice as common, while the model ranks cases as well as before. What needs another look?

Show the answer

Answer: a

AUC doesn't depend on how common the event is, but precision does. The same cut can now be too strict or too loose for what the mistakes cost.

Check yourself

You export a network with ONNX (torch) and add a static int8 copy. The export reports the copy's accuracy on sample rows it wasn't calibrated on. What should you still do before you deploy the int8 copy?

Show the answer

Answer: a

The copy was calibrated and checked on a small sample of training rows. Data that has shifted can push activations outside the calibrated ranges, so check the copy on data like the one it will score.

09

Call it from code

In the app

Start the server, create an endpoint, and copy your token from Copy curl. Then call it. Rows go in as {"rows": [...]}, and the answer holds predictions, plus probabilities and classes for a classifier. If the version has a predictive SD or a saved conformal calibration, the answer also holds predSd, an interval as predLower and predUpper, or a prediction set as predSet. Without one, those fields are left out.

Python
import requests

url = "http://127.0.0.1:8790/v1/models/churn:predict"
headers = {"Authorization": "Bearer YOUR_TOKEN"}
rows = {"rows": [{"age": 41, "plan": "plus", "visits": 3}]}

r = requests.post(url, json=rows, headers=headers, timeout=30)
r.raise_for_status()
print(r.json()["predictions"])
R
library(httr2)

url <- "http://127.0.0.1:8790/v1/models/churn:predict"
rows <- list(rows = list(list(age = 41, plan = "plus", visits = 3)))

resp <- request(url) |>
  req_auth_bearer_token("YOUR_TOKEN") |>
  req_body_json(rows) |>
  req_perform()
resp_body_json(resp)$predictions

Your own endpoint's name and features go where churn, age, plan and visits are. Try it shows the exact shape your model expects.

10

Recap

Recap
  • Use a batch unless a decision really can't wait.
  • The local server is for this machine; exports are how a model leaves it.
  • Follow an alias to move with promotions, or pin a version to stay put.
  • An endpoint returns a score. The threshold is a separate decision, and it can change while the model doesn't.