Serve a model over HTTP
Requires a Talario build. Licensed builds are available through sales. There is no public download. Availability
Talario serves a trained model in-process: the device, weights, and compiled forward graph are built once and stay warm, so each request runs with no reload, no IPC, no sidecar. This page is how to call a running Talario model - over HTTP, over a raw socket, directly in-process, and from Claude Code / an MCP server.
1. Start a server#
php/serve.php builds one resident model and exposes it three ways (all wrap the same
warm InferenceService). The reference model is a 64 → 128 → 10 MLP; swap the build
closure for your own architecture and set the dimensions to match.
# userland HTTP endpoint (no root, no php-fpm) - recommended to start php -d extension=modules/talario.so php/serve.php http cpu 127.0.0.1:5055 # raw line-protocol socket (lowest overhead, internal callers) php -d extension=modules/talario.so php/serve.php serve cpu 127.0.0.1:9999 # in-process smoke test (no network) php -d extension=modules/talario.so php/serve.php selftest cpu
Use gpu instead of cpu to serve on a Vulkan device.
2. HTTP API#
GET /health#
Liveness + the resident model's shape.
curl -s http://127.0.0.1:5055/health # {"status":"ok","device":"Talario CPU (SIMD / Tessero)","in":64,"out":10}
| field | meaning |
|---|---|
status |
"ok" when the model is resident |
device |
the backend actually serving (CPU or the GPU adapter name) |
in / out |
input feature count / output logit count of the resident model |
POST /infer#
Body is a JSON array of in floats; response is the output logits. Shorter inputs are
zero-padded and longer inputs truncated to in.
curl -s -X POST http://127.0.0.1:5055/infer \ -H 'Content-Type: application/json' \ -d '[0.1, 0.2, /* … 64 floats … */ 0.0]' # {"logits":[ -1.23, 0.44, … ]} // length = out
Argmax (class id) is a one-liner on the caller side, or use the programmatic
classify() in §5. Determinism holds: the same input yields the same logits on CPU and GPU
(bit-identical where attested: exact ops on six NVIDIA generations, and softmax, GELU,
layernorm, rmsnorm and attention on NVIDIA A10, A100 and H100 PCIe).
3. Raw socket protocol#
For internal, low-overhead callers: open a TCP connection, send one line = a JSON array
of in floats, read back one line = the JSON logits array. One request per connection.
printf '[%s]\n' "$(python3 -c 'print(",".join("0.0" for _ in range(64)))')" \ | nc 127.0.0.1 9999 # [ -1.23, 0.44, … ]
Keep the raw socket on localhost / a trusted network; put the HTTP mode behind your app's auth + reverse proxy for anything public.
4. FrankenPHP worker (production)#
php/serve_frankenphp.php is the production pattern: the model is built once per worker and
replayed per request. Configure via environment:
| env var | meaning |
|---|---|
KX_DEVICE |
cpu or gpu |
KX_IN, KX_H, KX_OUT |
input / hidden / output dims |
KX_WEIGHTS |
path to a .tal binary weights blob (optional) |
Requires a ZTS (thread-safe) build of the extension - FrankenPHP is thread-based. Default
NTS builds are fine for serve.php, CLI, and php-fpm. See serving.md and the build notes.
5. In-process (no HTTP) - when your app is the server#
If your PHP app (e.g. a Laravel route) runs the extension, skip HTTP entirely and call the model in-process - this is the zero-IPC path:
use Talario\{Device, InferenceService, Sequential, Linear}; use function Talario\relu; // built once (service provider / worker boot): $dev = new Device('gpu'); $svc = new InferenceService( $dev, fn($d) => new Sequential([ new Linear($d,64,128), relu(), new Linear($d,128,10) ]), batch: 1, inDim: 64, outDim: 10 ); // per request handler: $logits = $svc->infer($features); // warm model, one submission $class = $svc->classify($features); // argmax
6. Claude Code / MCP#
The HTTP endpoint (§2) is the substrate for agent/assistant use. Two ways to drive Talario from Claude Code:
A. As an MCP tool. Run a small MCP server that forwards to /infer, and register it in
Claude Code's MCP config. Minimal tool contract:
// tool: talario_infer
// input:
{ "features": [ /* `in` numbers */ ] }
// output:
{ "logits": [ /* `out` numbers */ ], "class": 3 } // class = argmax(logits)
The server is a thin wrapper: accept features, POST them to the running Talario endpoint,
return logits (+ class). Point it at TALARIO_ENDPOINT=http://host:5055 so the MCP layer
never needs the Talario source - only the live service.
B. Straight from a prompt / skill. Have Claude Code curl the endpoint:
curl -s -X POST "$TALARIO_ENDPOINT/infer" -H 'Content-Type: application/json' -d "$FEATURES"
Either way, Claude Code interacts with the running model.
7. Notes & limits#
- Auth/exposure: endpoints bind to localhost by default. For public exposure, front them with your app's authentication and a reverse proxy (TLS, rate limits). Do not expose the raw socket publicly.
- Shapes:
in/outare fixed by the resident model;/inferpads/truncates input toin. Query/healthto discover them. - Batching: the reference server is
batch: 1; raise the batch in yourInferenceServicebuild for throughput. - Repo visibility: none of the above requires the Talario source to be public. The service is the product surface.
Using a coding agent?
Copy a prompt for Serve a model over HTTP, with 5 exact API signatures.