Docs
Open app
On this page

Runtimes & SDK

View on GitHub

Run your model inside your own application. A downloaded model is one .tfpb file, and the 19th runtime predicts from it on the device’s CPU: no GPU, no network calls, and no Python needed for native apps. Predictions have the same fields as hosted predictions.

Get the SDK

Prebuilt SDK packages come with your account. GET /v1/model-runtimes on the Training API lists them, and GET /v1/model-runtimes?runtime_id=RUNTIME_ID returns one package’s download link and setup steps. Through MCP, ask your agent to use get_runtimes. Install a package once and reuse it for every model.

The runtime runs on:

  • Linux on x86-64 and ARM64, with glibc or as a static musl build
  • macOS on Apple silicon
  • Windows on x86-64
  • iOS and Android
  • Node.js and browsers through WebAssembly
LanguagePackage
C, C++, Zig, Golibtfp_sdk shared library with tfp.h, plus the static libtfp_sdk.a for Linux
RustNative client crate, or the tfp-sdk crate from source
Pythontfp_sdk wheel
JavaScript, TypeScriptnpm package with WebAssembly
SwiftXCFramework for iOS
KotlinAndroid library (AAR)

The runtime’s source code is at github.com/19thLabs/19th-runtime under the Apache 2.0 license, with build steps for each target.

Predict from a file

Put the rows to predict in a JSON array, one object per row, using the model’s input columns:

[{"plan": "basic", "reading": 0.5, "signup": "2024-01-15"}]

The native packages include the tfp-run command line. Predict, or print the model’s input columns, task and output fields with --info:

tfp-run model.tfpb rows.json
tfp-run model.tfpb --info
{
  "classes": [false, true],
  "predictions": [
    {
      "event_probability": 0.62,
      "label": true,
      "probabilities": [0.38, 0.62]
    }
  ]
}
from tfp_sdk import Model

rows = [{"plan": "basic", "reading": 0.5, "signup": "2024-01-15"}]

with Model.load_file("model.tfpb") as model:
    print(model.predict(rows)["predictions"])

JavaScript. In Node.js, load the file by path. In a browser, fetch the bytes and use loadBytes.

import { loadFile } from "@19th/runtime";

const rows = [{ plan: "basic", reading: 0.5, signup: "2024-01-15" }];

const model = await loadFile("model.tfpb");
try {
  console.log(model.predict(rows).predictions);
} finally {
  model.close();
}

C. tfp_open loads the model bytes and checks the file. tfp_predict takes the rows as JSON and returns JSON. Each call returns 0 on success and 1 on error, with the answer or the error message in the buffer.

#include "tfp.h"

TfpSession *model = NULL;
TfpBuffer out = {0};
if (tfp_open(model_bytes, model_len, &model, &out) == 0) {
  tfp_buffer_free(out);
  out = (TfpBuffer){0};
  int status = tfp_predict(model, rows_json, rows_len, 0, &out);
  /* out.data: out.len bytes of JSON, the answer or the error */
}
tfp_buffer_free(out);
tfp_destroy(model);
let mut model = tfp_native_client::Model::open(&model_bytes)?;
let rows = br#"[{"plan": "basic", "reading": 0.5, "signup": "2024-01-15"}]"#;
let answer = model.predict_json(rows, tfp_native_client::Point::Default)?;

Swift and Kotlin. Follow the setup steps returned for the iOS or Android package; they show how to load a model in your app.

Check the file. Compare the downloaded file’s byte count and SHA-256 with the values in the download response before you ship it. The SDK also checks the file’s own checksum when it loads it. Integrity receipts, tfp_create in C and Model::load in Rust, are optional for apps that pass a trusted hash alongside the model.

Text columns

A model trained with text columns takes each text column in one of two forms:

  • Raw text, such as "message": "My invoice is wrong". Only hosted predictions take raw text, because they run 19th’s language model for you.
  • Its vector, in a field named after the column with __emb added, such as message__emb. Hosted predictions and the runtime both take vectors.

The runtime doesn’t include a language model, so on your own hardware send the vector. Raw text without its vector returns TEXT_VECTOR_MISSING. Leave a vector out, or set it to null, when the text is missing.

tfp-run model.tfpb --info shows how to make each vector, in the column’s text_encoding:

{
  "text_encoding": {
    "field": "message__emb",
    "dimension": 256,
    "encoder": {
      "name": "Qwen/Qwen3-Embedding-4B",
      "revision": "5cf2132abc99cad020ac570b19d031efec650f2b",
      "instruction": "Represent this message for predicting the team.",
      "pooling": "last_token",
      "max_tokens": 512,
      "reduce": "mrl"
    }
  }
}

Embed the text with that open-weight model at that revision, using the instruction, pooling and token limit shown. Keep the first dimension values and L2-normalise them again; that is what mrl means. If your app can’t run the model, use hosted predictions, or train with your own embedding columns instead.

A few models can only run through hosted predictions. Their download options return downloadable: false with a hosted_only_reason; see Downloads and SDKs.

Speed and deployment

  • Hardware. The SDK picks the fastest path for the CPU it runs on: AVX-512 VNNI, AVX2, NEON or plain scalar code.
  • Threads. A model handle runs one call at a time. Fork it, with tfp_fork in C or fork() in Python and JavaScript, to get another handle that shares the model’s memory.
  • Static Linux builds. The musl packages have no glibc dependency, so they suit Alpine, scratch and distroless containers, and static Zig, Go and C builds. Link libtfp_sdk.a with musl libc and an unwinder, for example zig cc -target x86_64-linux-musl -static -Iinclude app.c lib/libtfp_sdk.a -lunwind -o app.
  • Model sizes. Turbo and Warpspeed files are smaller and predict faster than Fast. See Modes and sizes.