C API · gRPC · KServe v2 · bundles
A C API in process, and one port over gRPC.
A program can link libturbo and call its C API directly, or talk to
turbo-kserve, which loads bundles and serves them over the KServe v2
Open Inference Protocol. The same server hosts the analysis, search, catalog,
training, vocabulary and health services on its one port.
Two ways in, one library underneath.
Every answer the server gives comes from a turbo_* call in the C
header. The server is a projection of the library and adds nothing the
header does not have.
The libturbo C API.
include/turbo/turbo.h is a hand-written C11 and C++17 header. A
caller creates a runtime, loads a bundle, opens a session, writes inputs,
runs, and reads the result.
- turbo_runtime_createLists the devices the library finds, accelerators first, then the CPU.
- turbo_model_loadLoads a bundle: manifest, hashes, weights, tokenizer and settings.
- turbo_session_createOpens a session with pooling, normalization, truncation, prompt, precision tier and autotune options.
- turbo_embed_write_textWrites text, or token ids with
turbo_embed_write_tokens. - turbo_session_runRuns the task on the device.
- turbo_result_readReads the vectors, with a report of where each stage ran and the bytes that crossed to the device.
Three tasks
TURBO_TASK_EMBED: text or token ids in, one pooled vector per row or per token range out.TURBO_TASK_RERANK: query and passage pairs in, one relevance logit per pair out.TURBO_TASK_EXTRACTIVE_QA: a question and context windows in, start and end logits out, with abstention.
Tokenizer API
The tokenizer is exposed through the same header: encode, encode_pair, encode_spans, decode and count. WordPiece, Unigram, byte-level BPE and SentencePiece .model files are implemented in the library.
turbo_embed_write_ranges pools one vector per token range from a single encoder pass, which gives per-sentence and per-chunk vectors from one run over a document.
# Build the library and run the C example on the CPU
cargo build --release -p turbo
cc -std=c11 -I include docs/setup/embed.c -L target/release -lturbo \
-Wl,-rpath,$PWD/target/release -o embed
./embed testdata/tiny-bert-bundle 0 model
turbo-kserve: seven services on one port.
The server loads bundles from --model flags and serves these
services on the address given to --listen.
| Service | What it does |
|---|---|
inference.GRPCInferenceService | KServe v2 Open Inference Protocol: embed, rerank and extractive QA through ModelInfer |
turbo.result.v1.AnalysisService | Capabilities, bundle load and unload, AnalyzeStream, AnalyzeDocumentProgressive, graph and window inspection, chunk projection, and output formats |
turbo.search.v1.TurboSearchService | In-memory indexes, hybrid search with fusion and reranking, persist and seal, aliases and collections |
turbo.training.v1.TurboCatalogService | The model zoo catalog, installed models, licence acceptance and streamed installs |
turbo.training.v1.TurboTrainingService | Static models distilled from a served encoder, and classical components trained from streamed samples |
turbo.vocabulary.v1.TurboVocabularyService | Dictionary import, corpus vocabulary learning and download |
grpc.health.v1.Health | Standard gRPC health checks |
KServe v2 calls
ServerLive, ServerReady, ModelReady, ServerMetadata, ModelMetadata and ModelInfer. A ModelInfer request carries texts as BYTES, or ids, mask and optional types as INT32 tensors, and the reply is a vectors tensor of FP32 with the run’s summary as response parameters.
Serving a model
Each --model is comma-separated key=value settings: bundle, device (cpu, cuda:0, levelzero:0, metal:0, hailo:0, npu:0, or select), sessions, name, precision, max_batch and max_seq. One bundle can be served under two names at two precision tiers.
Security and metrics
The server speaks plaintext gRPC unless given --tls-cert and --tls-key; --tls-client-ca adds mutual TLS. --bearer-token and --admin-bearer-token authorize read and admin calls, and health checks stay open for probes. Calls that change server state need --admin. --metrics-listen serves Prometheus metrics on a separate listener.
# Build a bundle and serve it
cargo run --release -p turbo-bundle -- make \
minishlab/potion-base-8M \
upstream/potion-base-8M bundles/potion-base-8M
cargo build --release -p turbo-kserve
target/release/turbo-kserve --listen 127.0.0.1:8081 \
--model bundle=bundles/potion-base-8M,device=cpu,sessions=2
Token input buffers follow the device.
When a request carries token ids, the server copies them into buffers that the session holds. The placement of those buffers depends on the backend.
| Backend | Token input buffer placement |
|---|---|
| CPU, CUDA, Level Zero GPU, Metal | Pinned, page-locked host memory the device can read, TURBO_PLACE_PINNED |
| Intel NPU, Hailo | Host memory, TURBO_PLACE_HOST, the placement these backends allocate |
Model bundles and the zoo.
A bundle is a directory with a manifest and hashes, the weights, the tokenizer, the model’s settings and reference vectors. The tools around it build, verify and catalog them.
turbo-bundle
Builds a bundle from a recipe: fetches the pinned upstream files, runs the conversion and reference pipeline in pinned containers with no network, writes the manifest, and verifies the result with the library’s own loader. Commands include make, fetch, reference, seal, verify, distill and catalogue.
turbo-zoo
An index of models, heads, lexicons, centroid sets and datasets, each with its licence, attribution and training data. The fetcher refuses an artifact whose licence class has not been accepted.
Catalog service
TurboCatalogService lists the catalog, records licence acceptances and streams installs. A file is handed to a client only when its size and SHA-256 match the catalog.
Client libraries and release archives.
Clients in other languages are generated from the protos in server/proto.
| Path | What it is |
|---|---|
| clients/rust | Rust client that combines in-process analysis, local libturbo sessions and pooled server calls |
| clients/python | Generated Python gRPC stubs, turboembed-proto |
| clients/java | Generated Java gRPC stubs, ai.pipestream:turboembed-grpc |
| clients/java-api | The in-process Java API, Java 21 and later |
| clients/java-panama | libturbo through the Foreign Function and Memory API, Java 25 and later |
| clients/java-jni | libturbo through JNI, Java 21 and later and Android |
| Release archive | Backends |
|---|---|
| linux-x86_64.tar.gz | CPU, CUDA and NPU |
| macos-arm64.tar.gz | Metal and CPU |
| linux-aarch64.tar.gz | CPU |
| windows-x86_64.zip | CPU and NPU |
| android.tar.gz | CPU, for the JNI binding |
| turboembed-proto tar.gz | The .proto files |
A v<version> tag builds the archives with SHA-256 sums and also
pushes two server images to GHCR: ghcr.io/ai-pipestream/turbo-kserve:<version>
(CPU, amd64 and arm64) and :<version>-cuda (CPU and CUDA, amd64).
Keep exploring.
The hardware behind the C API, and the analysis the server hosts.


