npm SDK overview
The @sakutto/* packages are TypeScript libraries extracted from the Sakutto browser extension. They expose the translation pipeline, model management, browser inference, OCR, and PDF layout helpers for reuse. You do not need them just to use the extension.
Packages
Section titled “Packages”| Package | Purpose | Install |
|---|---|---|
@sakutto/core |
PFML3 prompts, translation pipeline, batching, caching, and the local-server client | npm install @sakutto/core |
@sakutto/models |
Verified PLaMo / PP-OCRv6 downloads, resumable files, OPFS / Node storage | npm install @sakutto/models |
@sakutto/runtime-wllama |
Run a verified PLaMo GGUF in the browser with Sakutto’s patched wllama | npm install @sakutto/runtime-wllama |
@sakutto/ocr |
PP-OCRv6 pipeline and ONNX Runtime Web adapter | npm install @sakutto/ocr onnxruntime-web |
@sakutto/pdf |
Pure PDF line grouping, layout, and translated-text fitting helpers | npm install @sakutto/pdf |
Install by use case
Section titled “Install by use case”Translate in a browser app
Section titled “Translate in a browser app”npm install @sakutto/core @sakutto/models @sakutto/runtime-wllamaThis combination downloads and verifies the model, stores it in OPFS, runs it with wllama, and connects it to the translation pipeline.
Add OCR in a browser app
Section titled “Add OCR in a browser app”npm install @sakutto/core @sakutto/models @sakutto/ocr onnxruntime-webonnxruntime-web is a peer dependency. Serve the OCR models and ONNX Runtime WASM / worker files from your own application origin.
Connect to a local inference server
Section titled “Connect to a local inference server”npm install @sakutto/coreUse only the client that sends PFML3 prompts to an OpenAI-compatible raw /v1/completions endpoint.
Use PDF layout helpers only
Section titled “Use PDF layout helpers only”npm install @sakutto/pdfThe package does not open or render PDFs. It groups extracted TextPieces into lines, lays them out, and fits translations using a width-measurement callback for your font.
Minimal translation example
Section titled “Minimal translation example”import { createTranslator } from '@sakutto/core';import { createModelManager, DEFAULT_MODEL_ID } from '@sakutto/models';import { openOpfsModelStore } from '@sakutto/models/browser';import { createWllamaRuntime } from '@sakutto/runtime-wllama';
const store = await openOpfsModelStore('my-app');const models = createModelManager({ store });
// Call this only after the user accepts the PLaMo Community License.await models.download(DEFAULT_MODEL_ID, { acceptLicense: 'plamo-community' });
const runtime = await createWllamaRuntime(await models.open());try { const translator = createTranslator({ runtime }); console.log(await translator.translateText('こんにちは', { src: 'ja', tgt: 'en' }));} finally { await runtime.dispose();}