Installation
Polyglot SDKs plus a standalone CLI. Most packages ship prebuilt binaries for Linux (x86_64/aarch64), macOS, and Windows — no compile step needed.
CLI / Docker
Section titled “CLI / Docker”No SDK, no code — just your terminal.
curl -fsSL https://raw.githubusercontent.com/xberg-io/xberg/main/scripts/install.sh | bashbrew trust xberg-io/tapbrew install xberg-io/tap/xbergcargo install xberg-clidocker pull ghcr.io/xberg-io/xberg-cli:latestdocker run -v $(pwd):/data ghcr.io/xberg-io/xberg-cli:latest extract /data/document.pdfdocker pull ghcr.io/xberg-io/xberg:latestChoose your language
Section titled “Choose your language”- Python
pip install xberg- TypeScript (Node.js / Bun)
npm install @xberg-io/xberg- TypeScript (Browser / Edge)
npm install @xberg-io/xberg-wasm- Rust
cargo add xberg- Go
go get github.com/xberg-io/xberg/packages/go@latest- Java
implementation 'io.xberg:xberg:1.0.0-rc.14'- Kotlin Android
implementation("io.xberg:xberg-android:1.0.0-rc.14")- Ruby
gem install xberg- Swift
.package(url: "https://github.com/xberg-io/xberg.git", from: "1.0.0-rc.14")- C# / .NET
dotnet add package XbergIo.Xberg- PHP
composer require xberg-io/xberg- Elixir
{:xberg, "~> 1.0.0-rc.14"}- C / C++
cargo build -p xberg-ffi- Dart / Flutter
dart pub add xberg- Zig
zig fetch --save https://github.com/xberg-io/xberg/archive/refs/tags/v1.0.0-rc.14.tar.gzSystem requirements
Section titled “System requirements”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.
HEIF / HEIC / AVIF support
Section titled “HEIF / HEIC / AVIF support”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.
GPU Acceleration
Section titled “GPU Acceleration”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.
Language-specific notes
Section titled “Language-specific notes”Edge cases and alternative install methods where they come up.
TypeScript
Section titled “TypeScript”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>implementation 'io.xberg:xberg:1.0.0-rc.14'Requires Java 25+ (FFM/Panama API). Native libraries are bundled in the JAR.
Elixir
Section titled “Elixir”Add to mix.exs:
def deps do [ {:xberg, "~> 1.0.0-rc.14"} ]endmix deps.getShips prebuilt NIF binaries via RustlerPrecompiled. Falls back to compiling from source if no prebuilt matches your platform (requires Rust).
go get github.com/xberg-io/xberg/packages/go@latestEnable features selectively in Cargo.toml:
[dependencies]xberg = { version = "1", features = ["pdf", "ocr", "chunking"] }# Default features are tokio-runtime + simd-utf8; format and analysis features are opt-in.C / C++
Section titled “C / C++”Build the FFI library from source:
cargo build --release -p xberg-ffiThis produces libxberg_ffi.a and a header at crates/xberg-ffi/xberg.h. Link into your project:
HEADER_DIR = path/to/crates/xberg-ffiLIBDIR = 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)Dart / Flutter
Section titled “Dart / Flutter”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
Section titled “Kotlin”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", ...).
Development setup
Section titled “Development setup”For working on the Xberg repository itself:
task setup # installs all language toolchainstask lint # linters across all languagestask dev:test # full test suiteSee Contributing for conventions and expectations.