Reference
Arcane.ai.chat()
Sends a chat request through the configured provider.
This focused page is derived from the mechanically checked full member inventory.
Syntax
Arcane.ai.chat(request)
Parameters
request: AIChatRequest
Return value
Description
Sends a chat request through the configured provider.
Overview
Arcane.ai.chat(request) sends one non-streaming chat request through the
configured Ollama or OpenAI provider and normalizes the result. Prefer it when
application code should remain provider-neutral. Bind a request to the profile
you presented by sending expectedProvider; Arcane then rejects a concurrent
provider change instead of silently switching providers.
Parameters
request is a closed AIChatRequest. messages is required and contains 1-128
exact {role, content} records. Roles are system, user, or assistant;
each content string is nonempty and at most 131,072 characters, and combined
content is at most 512 KiB. Portable optional fields are expectedProvider and
format ("json", "", or null). model, options, tools,
keep_alive, think, logprobs, and top_logprobs are Ollama-only controls.
An omitted local model uses the saved default; OpenAI always uses the saved,
account-validated model.
Return value
It resolves to normalized AIChatResult: provider, model, an assistant
message, done, doneReason, promptEvalCount, and evalCount. Ollama can
also supply bounded message.thinking and message.toolCalls. Response content
and thinking are each retained up to 4 MiB.
Availability
The current public method requires ai.inference on desktop Core. It can use
the selected local Ollama service or protected OpenAI credential. The current
Android projection exposes direct Arcane.ollama.chat(), not this
provider-neutral method.
Errors and recovery
Correct invalid request, message, model, format, or context errors before
retrying. AI_PROVIDER_CHANGED means refresh Arcane.ai.profile() and let the
user confirm the new provider. OpenAI can reject with
OPENAI_NOT_CONFIGURED, OPENAI_MODEL_REQUIRED,
OPENAI_MODEL_UNAVAILABLE, network, bounded-response, or invalid-response
errors. Local model admission errors require a currently runnable admitted
model or the managed lifecycle; Arcane never falls back to another provider.
Streaming, cancellation, and events
This API resolves one normalized result and emits no chunk event. The wrapper uses a 130-second renderer timeout and does not expose a per-call signal. Desktop Core can cooperatively cancel the underlying method when it receives a host control frame, including page teardown, but timeout or teardown should still be treated as an unknown completion boundary rather than a retry token.
Example
const arcane = globalThis.Arcane;
const profile = await arcane.ai.profile();
const result = await arcane.ai.chat({
expectedProvider: profile.provider,
messages: [
{role: 'system', content: 'Answer briefly and accurately.'},
{role: 'user', content: 'Explain the current model in one sentence.'}
]
});
console.info(result.message.content);