API Reference / agent / tools / system /

serving.py

REST serving of trained models.

These are result-formatting wrappers over the root serving API (tuiml.serve / tuiml.stop_server / tuiml.server_status). They own no server state: the root tuiml.serving.server._SERVERS registry is the only one, so a server started by an agent is visible to tuiml.server_status() and vice versa, and both use the same "host:port" server ids.

Functions

Func

execute_serve_model

Line 42
execute_serve_model(**kwargs) -> Dict[str, Any]

Start a REST API server to serve a trained model.

Backs the tuiml_serve_model tool. Resolves the model, then delegates the whole server lifecycle to tuiml.serve, which binds the port, waits for uvicorn to actually report ready, and registers the server in the single process-wide registry.

Parameters

model_id
str = None
Identifier of a trained model from tuiml_train. One of model_id / model_path is required (both arrive via **kwargs, like all parameters below).
model_path
str = None
Explicit path to a serialized model file.
port
int = 8000
TCP port to bind; must be free.
host
str = '127.0.0.1'
Interface to bind the server to. Anything other than loopback puts the API on the network; it stays authenticated, but the traffic is unencrypted.

Returns

result
dict
On success: status ('success'), server_id ('host:port'), model_id, url, auth_token, auth, endpoints (name -> URL map) and example_curl. On failure: status ('error'), error, error_type and optionally suggestion.
Func

execute_stop_server

Line 165
execute_stop_server(**kwargs) -> Dict[str, Any]

Stop one or all running model serving servers.

Backs the tuiml_stop_server tool; delegates to tuiml.stop_server.

Parameters

server_id
str = None
Identifier of the server to stop (arrives via **kwargs). When omitted, every running server is stopped.

Returns

result
dict
On success: status ('success') and message; stopping all servers also returns stopped (list of {server_id, model_id, port}). On failure: status ('error'), error and optionally suggestion / error_type.
Func

execute_server_status

Line 222
execute_server_status(**kwargs) -> Dict[str, Any]

Get status of running model serving servers.

Backs the tuiml_server_status tool; delegates to tuiml.server_status. Takes no arguments (any **kwargs are ignored). Reports every server in the process, whether it was started by an agent tool or by tuiml.serve() directly.

Returns

result
dict
status ('success'), count, and servers -- a list of {server_id, model_id, url, host, port}.