Reference
Arcane.ollama.chat()
Runs native Ollama chat after the host re-admits the exact requested model, optionally streamed. An admitted Android host proxies only this inference operation to its user-managed fixed loopback service and exposes no model mutation or lifecycle operation.
This focused page is derived from the mechanically checked full member inventory.
Syntax
Arcane.ollama.chat(request, options?)
Parameters
request: OllamaChatRequest; options?: OllamaStreamControls or OllamaChunkCallback
Return value
Description
Runs native Ollama chat after the host re-admits the exact requested model, optionally streamed. An admitted Android host proxies only this inference operation to its user-managed fixed loopback service and exposes no model mutation or lifecycle operation.
Overview
Arcane.ollama.chat(request, streamOptions?) sends a provider-native Ollama
chat after the host rechecks package policy, model identity, and current
admission. Use it when Ollama-specific messages, tools, options, or streaming
are intentional; use Arcane.ai.chat() for a normalized provider-neutral
result.
Parameters
On desktop Core, request is a closed plain object of at most 8 MiB with
required model and provider-native messages. Optional fields are tools,
format, options, keep_alive, think, logprobs, and top_logprobs;
options.num_ctx, when present, is 1,024-262,144. streamOptions can be a
named callback or {onChunk, signal, timeoutMs} and is not forwarded to
Ollama.
Android admits a narrower generated contract for explicitly approved apps: 1-128
bounded messages with system, user, assistant, or tool roles; bounded
format, think, tools, and selected generation options; at most 512 KiB of
combined message content and 768 KiB encoded request data. Do not send desktop-
only keep_alive or log-probability fields when targeting Android.
Return value
It resolves to the final bounded provider-native chat envelope. With
onChunk, each callback receives (chunk, {operation: "chat", streamId}) and
the promise resolves to the final provider chunk. Direct provider fields are
not normalized into AIChatResult.
Availability
The method requires ai.inference. Desktop Core admits it according to package
policy and native resource checks. Android projects the bounded user-managed-
loopback form only to explicitly approved apps and repeats package-policy/provider
inspection before dispatch. Plain browser previews have no Ollama authority.
Errors and recovery
Correct invalid request, message, option, model, stream, size, or response errors locally. Policy, verified-model, installation, queue, isolated-operation, and capacity errors require a runnable admitted model; never bypass them by calling loopback directly. Android can additionally report queue, timeout, cancel, invalid-provider-response, or response-size errors. No branch silently changes provider.
Streaming, cancellation, and events
The wrapper filters internal ollama.chunk events by its generated stream ID.
The default renderer timeout is ten minutes. A supplied signal cancels the
renderer request; desktop Core cooperatively destroys its provider request and
Android cancels the owned chat task. Store application cleanup for any external
controller or UI listener.
Example
const arcane = globalThis.Arcane;
const status = await arcane.localAI.status();
const model = status.models.ollama.find(function findRunnableChatModel(candidate) {
return candidate.runnable === true;
});
if (!model) {
throw new Error('No admitted local model is currently runnable.');
}
function handleChatChunk(chunk, metadata) {
console.info(metadata.operation, chunk.done === true ? 'done' : 'working');
}
const result = await arcane.ollama.chat({
model: model.id,
messages: [{role: 'user', content: 'Reply with one short sentence.'}]
}, {
onChunk: handleChatChunk,
timeoutMs: 120000
});
console.info(result.message?.content ?? 'No text returned');