Skip to main content
A free-form chat-completions LLM (optionally vision-capable) — the JS analogue of the ask primitive. Given a prompt, optional accessibility/structural text, and zero or more images, [AskModel.ask] returns the model’s response as a plain string. The wire format is OpenAI-compatible chat completions, so any provider config that points at such an endpoint works.

Constructor

Returns

AskModel

Properties

string
required
The wire-level model identifier sent in the request body.

Methods

ask()

Ask the model a question, optionally grounded in accessibility text and/or images.
  • prompt: the question or task to answer.
  • text: optional accessibility-tree (or any) text included as structural context. Pass null / omit to skip.
  • images: zero or more images to attach. Each is encoded as a base64 data URL in a model-supported format and sent as an image_url chat content part. Pass null / omit for none.
Returns the trimmed assistant response on success.

Parameters

string
required
null | string
null | Image[]

Returns

string

availableAliases()

Every LLM model alias accepted by byAlias on this machine, deduplicated and sorted alphabetically. Use to discover what aliases the loaded config (bundled defaults plus any user provider files) advertises.

Returns

string[]

byAlias()

Resolve a model alias against the loaded config (e.g. "openrouter_gpt_4o_mini" / "openrouter_claude_opus" from the bundled openrouter provider, or any alias declared by a user provider). Throws if the alias is unknown.

Parameters

string
required

Returns

AskModel

checkAuth()

Check that the API key works. Throws if it doesn’t. Call right after creating the model so a bad key fails fast, before any UI automation has had a chance to steal focus:

default()

First LLM model advertised by the first LLM-capable provider in the loaded configuration whose credentials are currently available. Providers with missing credentials are skipped; throws if no provider remains available.

Returns

AskModel