All examples
Model APIs

A model inference service class

Preload a fitted classifier once and retain an immutable native API application in a service class.

Download .aner source
api_checkpoint.aner
// First run api_train_checkpoint.aner in this working directory.
// Loads once; Ctrl+C stops the foreground API.
import aner.api
import aner.ml

class InferenceService {
    let app: APIApp

    fn run() {
        app.serve()
    }
}

let model = ml.load_classifier("iris.anermodel")
let service = InferenceService(
    app: api.app("Iris inference").model("/predict", model))
service.run()

Make it your experiment.

With Aner installed, save this program as examples/api_checkpoint.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/api_checkpoint.aner
aner run examples/api_checkpoint.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the compatible native Aner development engine with aner.api and VS Code extension 0.1.35 or newer. Checking opens no listener. Serving runs in the foreground until stopped. Checkpoint examples require iris.anermodel prepared by api_train_checkpoint.aner in the working directory. Native HTTPS requires a compatible TLS build, a trusted certificate chain and owner protected private key, an explicit permitted hostname and a dedicated inbound bearer reference. Local completion requires the named model already served by Ollama. See Model inference APIs for schemas, transport, deployment, deadlines and device preservation.

Iris and Wine are teaching datasets with their own attribution. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner