orynby OCNO

Oryn Browser SDK · Developer alpha

Build for
local AI.

Add local AI to a website with one SDK. Your app requests work; Oryn manages permission, models and engines on the user’s computer.

How Oryn works

  1. Your website asks. The SDK describes the task and model requirements.
  2. Oryn checks and prepares. The browser handles permission, model selection, downloads and device resources.
  3. The hardware does the work. Oryn’s engine runs the model locally and returns results to your app.

Before you start

The TypeScript SDK is framework-independent. Production websites use HTTPS; loopback development is supported. Importing the client is safe during server-side rendering, but perform feature work in the browser.

The SDK package is not published to the registry yet. The examples below describe the current developer-alpha API, not an available public package installation. Oryn Browser’s current target is Apple Silicon Macs.

Browser installation and availability ↗

A local chat request

Call this function from a user action, such as pressing Send. Supply your app’s UI callbacks and an AbortSignal connected to its Cancel button. Handle rejected calls in your app’s error UI.

import { createLocalAIClient, invokeStream } from "@ocno/oryn-sdk";

const localAI = createLocalAIClient();

async function runChat({ message, signal, onEvent, onModel, onUnavailable }) {
  const capabilities = await localAI.getCapabilities();
  if (!capabilities.runtimeAvailable) {
    onUnavailable(); // Your cloud option or another way to continue.
    return;
  }

  const session = await localAI.models.request({
    role: "chat",
    preferredModel: {
      provider: "huggingface",
      repository: "Qwen/Qwen2.5-0.5B-Instruct",
    },
    requirements: {
      task: "text-generation",
      inputModalities: ["text"],
      outputModalities: ["text"],
      capabilities: { chat: true, streaming: true },
    },
    substitution: { automatic: "compatible" },
  }, { signal });

  try {
    onModel(session.resolution); // Show the actual model and trust status.
    for await (const event of invokeStream(localAI, {
      sessionId: session.sessionId,
      input: { messages: [{ role: "user", content: message }] },
    }, { signal })) {
      onEvent(event);
    }
  } finally {
    await localAI.models.releaseSession(session.sessionId);
  }
}

This is a JavaScript-compatible SDK example. The model name is illustrative, not a guarantee of support. The website does not execute this code or start AI jobs.

API at a glance

Method or helperWhat it does
getCapabilities()Checks availability. Outside Oryn, runtimeAvailable is false. Detection does not grant permission or load models.
models.request(request, options)Requests an eligible model session. Inspect the returned resolution.
invoke(request)Submits a job. Subscribe first if using the low-level event API.
subscribe(callback)Receives your site’s job events. Returns an unsubscribe function.
invokeStream(client, request, options)Subscribes before submission and yields job events as an async iterable.
invokeAndWait(client, request, options)Waits for completion and returns the result.
cancel(jobId)Requests cancellation; interruption may happen at the next safe runner point.
models.releaseSession(sessionId)Releases the session when your feature is finished.

Ask for a task. Check the chosen model.

preferredModel expresses your preference. requirements describes the task, input/output types and needed features. certifiedModels lists alternatives your app has tested; it does not make them Oryn-certified.

Automatic substitution can be none, certified-only or compatible. The browser remains in charge of the permitted choice. Read session.resolution to show the actual model, compatibility, trust and whether a substitution occurred.

Support depends on the exact model files, version, task and device. An eligible unverified version needs a separate user trust decision. A website cannot bypass that decision or override blocked files, unsupported execution or resource limits.

Use artifacts for files and media

Artifacts are browser-managed handles for binary inputs and outputs. Use artifacts.create(file, { lifetime: "session" }) and pass the returned ID in the task’s input. The input field depends on the task; transcription can use audioArtifactId.

  • artifacts.getUrl(id) provides a URL for media display.
  • artifacts.readBlob(id) reads an artifact into memory.
  • artifacts.saveAs(id, options) opens the browser’s save UI.
  • artifacts.release(id) releases access when you are finished.

IDs and URLs are restricted to the authorized site; they are not filesystem paths. Creating an artifact does not upload it. Any website upload is a separate action.

Handle refusal, errors and cancellation

Handle LocalAIError by its code, not its English message. Common cases include RUNTIME_NOT_AVAILABLE, USER_DENIED, MODEL_OUT_OF_MEMORY and JOB_QUEUE_FULL.

Connect your Cancel action to an AbortController and pass its signal to the helpers. They request cancellation after a job exists. Release sessions in finally and unsubscribe when using the low-level event API. Changing browser tabs does not automatically cancel a job.

What stays under the user’s control

Oryn owns permission, model choice, scheduling and trusted cancellation. Your site receives its own authorized results and job events. It cannot enumerate all installed models, inspect another site’s work, obtain local filesystem paths or access native engines directly.

Local processing does not define your website’s data practices. Explain any storage, uploads and cloud alternatives clearly. Keep private model inputs out of unrelated analytics or advertising flows.