Skip to content

Installation

Polyglot SDKs plus a standalone CLI. Most packages ship prebuilt binaries for Linux (x86_64/aarch64), macOS, and Windows — no compile step needed.

No SDK, no code — just your terminal.

Terminal window
curl -fsSL https://raw.githubusercontent.com/xberg-io/xberg/main/scripts/install.sh | bash

CLI Usage API Server Guide

  • Python

Terminal window
pip install xberg

API Reference Quick Start

  • TypeScript (Node.js / Bun)

Terminal window
npm install @xberg-io/xberg

API Reference Quick Start

  • TypeScript (Browser / Edge)

Terminal window
npm install @xberg-io/xberg-wasm

API Reference Quick Start

  • Rust

Terminal window
cargo add xberg

API Reference Quick Start

  • Go

Terminal window
go get github.com/xberg-io/xberg/packages/go@latest

API Reference Quick Start

  • Java

implementation 'io.xberg:xberg:1.0.0-rc.14'

API Reference Quick Start

  • Kotlin Android

implementation("io.xberg:xberg-android:1.0.0-rc.14")

API Reference Quick Start

  • Ruby

Terminal window
gem install xberg

API Reference Quick Start

  • Swift

.package(url: "https://github.com/xberg-io/xberg.git", from: "1.0.0-rc.14")

API Reference Quick Start

  • C# / .NET

Terminal window
dotnet add package XbergIo.Xberg

API Reference Quick Start

  • PHP

Terminal window
composer require xberg-io/xberg

API Reference Quick Start

  • Elixir

{:xberg, "~> 1.0.0-rc.14"}

API Reference Quick Start

  • C / C++

Terminal window
cargo build -p xberg-ffi

API Reference Quick Start

  • Dart / Flutter

Terminal window
dart pub add xberg

API Reference Quick Start

  • Zig

Terminal window
zig fetch --save https://github.com/xberg-io/xberg/archive/refs/tags/v1.0.0-rc.14.tar.gz

API Reference Quick Start


Only relevant if building from source or enabling OCR:

Dependency When you need it
AVX/AVX2 CPU instructions Required for ONNX Runtime features (PaddleOCR, layout detection, embeddings, reranking, auto-rotate, transcription) on x86_64
Rust toolchain (rustup) Building any native binding from source
C/C++ compiler Building native bindings (Xcode command-line tools / build-essential / MSVC)
Tesseract OCR Optional — brew install tesseract / apt install tesseract-ocr
libheif (HEIC / HEIF / AVIF) Optional — brew install libheif / apt install libheif-dev / dnf install libheif-devel

PDF extraction uses pdf_oxide and has no external PDF runtime dependency.

The Wasm package (@xberg-io/xberg-wasm) has zero system dependencies.

Pixel decoding for Apple HEIC photos, HEIF still images, AVIF, HEIC sequences (.heics), and AVCS requires the heic Cargo feature plus the system libheif library (with libde265 for HEVC and libaom for AV1):

  • macOS: brew install libheif
  • Debian / Ubuntu: apt install libheif-dev
  • Fedora: dnf install libheif-devel
  • Windows (vcpkg): vcpkg install libheif[hevc,aom]:x64-windows

Enable the feature when building from source:

xberg = { version = "1", features = ["heic", "ocr"] }

heic is included in the full aggregate feature. HEIC pixel decoding is not available on wasm-target or android-target (libheif is a C library with no working WASM/Android build story). EXIF metadata extraction from HEIC / HEIF / AVIF works on every target via the pure-Rust nom-exif integration.

Xberg bundles a CPU-only ONNX Runtime — ML features (PaddleOCR, layout detection, embeddings, reranking, auto-rotate, transcription) work out of the box on CPU.

For GPU acceleration, install a GPU-enabled ONNX Runtime and set ORT_DYLIB_PATH:

Platform Install Set ORT_DYLIB_PATH
Linux (CUDA) Download from ONNX Runtime releases export ORT_DYLIB_PATH=/path/to/libonnxruntime.so
Python (any OS) pip install onnxruntime-gpu Point at the pip package’s capi/ directory
macOS (CoreML) Works with bundled ORT — no extra setup needed

See AccelerationConfig and ORT_DYLIB_PATH for details.


Edge cases and alternative install methods where they come up.

Two npm packages target different runtimes:

Package Best for Performance
@xberg-io/xberg Node.js, Bun — server-side apps Native (100%)
@xberg-io/xberg-wasm Browsers, Deno, Cloudflare Workers Wasm (~60-80%)

Both work with pnpm (pnpm add) and Yarn (yarn add) as well.

Supported runtimes: Chrome 74+, Firefox 79+, Safari 14+, Edge 79+, Node.js 22+, Deno 1.35+, Cloudflare Workers.

<dependency>
<groupId>io.xberg</groupId>
<artifactId>xberg</artifactId>
<version>1.0.0-rc.14</version>
</dependency>

Requires Java 25+ (FFM/Panama API). Native libraries are bundled in the JAR.

Add to mix.exs:

def deps do
[
{:xberg, "~> 1.0.0-rc.14"}
]
end
Terminal window
mix deps.get

Ships prebuilt NIF binaries via RustlerPrecompiled. Falls back to compiling from source if no prebuilt matches your platform (requires Rust).

Terminal window
go get github.com/xberg-io/xberg/packages/go@latest

Enable features selectively in Cargo.toml:

Cargo.toml
[dependencies]
xberg = { version = "1", features = ["pdf", "ocr", "chunking"] }
# Default features are tokio-runtime + simd-utf8; format and analysis features are opt-in.

Build the FFI library from source:

Terminal window
cargo build --release -p xberg-ffi

This produces libxberg_ffi.a and a header at crates/xberg-ffi/xberg.h. Link into your project:

HEADER_DIR = path/to/crates/xberg-ffi
LIBDIR = path/to/target/release
CFLAGS = -Wall -Wextra -I$(HEADER_DIR)
LDFLAGS = -L$(LIBDIR) -lxberg_ffi -lpthread -ldl -lm
my_app: my_app.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)

API Reference →

Pure-Dart and Flutter consumers share the same package. Dart SDK 3.0 or higher is required. Flutter is supported on macOS, iOS, Android, Linux, and Windows; Flutter Web is not supported because the runtime is a native dynamic library delivered via flutter_rust_bridge. For Flutter projects use flutter pub add xberg instead of dart pub add xberg.

Kotlin/JVM consumers use the Java artifact (io.xberg:xberg) directly; Kotlin interoperates with the generated Java records and static facade.

Kotlin Android uses the Android AAR (io.xberg:xberg-android). It embeds JNI libraries for arm64-v8a and x86_64, targets Android API 21+, and uses the android-target feature set, which excludes most ORT-dependent inference features (PaddleOCR, layout detection, embeddings, reranking, transcription). Document-orientation detection runs through the pure-Rust tract engine (auto-rotate-tract) instead, so it is available on x86_64 as well as arm64-v8a.

Swift Package Manager from swift-tools-version: 6.0 upward. Package.swift declares macOS 13+ and iOS 16+; SwiftPM has no platform declaration for Linux, so no minimum is stated there. The package pulls a prebuilt static library through a binaryTarget (RustBridgeBinary), so consuming it needs no local cargo build.

Requires Zig 0.16.0 or higher (declared via minimum_zig_version in build.zig.zon). The Zig binding consumes the C FFI surface from xberg-ffi via linkSystemLibrary; the build expects the consumer to provide a search path to the prebuilt libxberg_ffi and the C header xberg.h. The zig fetch command above pins the source archive in build.zig.zon; wire it into build.zig via b.dependency("xberg", ...).


For working on the Xberg repository itself:

Terminal window
task setup # installs all language toolchains
task lint # linters across all languages
task dev:test # full test suite

See Contributing for conventions and expectations.