Arcane OS Docs Development only

Reference

Arcane.ollama.generate()

Generates text after Core re-admits the exact requested model; optionally streams chunks.

  • Reference

This focused page is derived from the mechanically checked full member inventory.

Syntax

Arcane.ollama.generate(request, options?)

Parameters

request: OllamaGenerateRequest; options?: OllamaStreamControls or OllamaChunkCallback

Return value

Promise<OllamaGenerateResponse>

Description

Generates text after Core re-admits the exact requested model; optionally streams chunks.

Overview

Arcane.ollama.generate(request, streamOptions?) calls Ollama's direct generate API after Core re-admits the exact model and requested context. Use it only when provider-native generation fields or chunks are required; use Arcane.ai.chat() for provider-neutral application chat.

Parameters

request is a closed plain object, encoded to at most 8 MiB. Required model uses the Ollama name pattern. Supported provider fields are prompt, suffix, images, format, options, system, template, context, raw, keep_alive, think, logprobs, and top_logprobs. When supplied, options.num_ctx is a safe integer from 1,024 through 262,144.

streamOptions can be a named chunk callback or {onChunk, signal, timeoutMs}. Pass a genuine AbortSignal and a positive finite timeout; callers must not send the wrapper-owned stream or streamId fields.

Return value

Without chunk delivery, it resolves to Ollama's bounded provider-native generate envelope. With onChunk, the callback receives (chunk, {operation: "generate", streamId}) for each filtered stream record, and the promise resolves to the final provider chunk.

Availability

This is a desktop Core method requiring ai.inference. Verified app models can be ensured or repaired before final admission. Unverified installed-model inference additionally requires ai.models.unverified.inference and remains inference-only. Applications with an isolated-model contract must use their application-owned isolated API. Android does not project direct generate.

Errors and recovery

Correct invalid request, model, stream, serialization, size, and context errors locally. Model policy, verification, installation, isolated-operation, and resource-admission errors require a currently admitted model or the documented managed workflow. Provider failures reject as local-Ollama request errors; Arcane does not fall back to OpenAI.

Streaming, cancellation, and events

Chunk delivery is backed by internal ollama.chunk events filtered to the wrapper-created stream ID; callers normally use onChunk, not a global event subscription. The default timeout is ten minutes. Aborting the supplied signal rejects the renderer promise, sends a cancel control, and desktop Core cooperatively destroys the active provider request. A chunk-callback exception is logged by the event dispatcher; own callback errors explicitly if they must fail application work.

Example

const arcane = globalThis.Arcane;
const status = await arcane.localAI.status();
const model = status.models.ollama.find(function findRunnableModel(candidate) {
    return candidate.runnable === true;
});

if (!model) {
    throw new Error('No admitted local model is currently runnable.');
}

const controller = new AbortController();

function handleGenerateChunk(chunk, metadata) {
    console.info(metadata.operation, chunk.done === true ? 'done' : 'working');
}

const finalChunk = await arcane.ollama.generate({
    model: model.id,
    prompt: 'Write one short, credential-free greeting.'
}, {
    onChunk: handleGenerateChunk,
    signal: controller.signal,
    timeoutMs: 120000
});

console.info(finalChunk.done === true);

Reference group

AI and Ollama

Repository and reviewed source access