> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AskModel

> A free-form chat-completions LLM (optionally vision-capable) — the JS analogue of the primitive.

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

```typescript
AskModel(): AskModel
```

### Returns

<code>[AskModel](/simulang-js/api/v14.0.0/classes/AskModel)</code>

## Properties

<ResponseField name={"name"} type={"string"} required>
  The wire-level model identifier sent in the request body.
</ResponseField>

## Methods

### ask()

```typescript
ask(prompt: string, text?: null | string, images?: null | Image[]): string
```

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

<ResponseField name={"prompt"} type={"string"} required />

<ResponseField name={"text"} type={"null | string"} />

<ResponseField name={"images"} type={"null | Image[]"}>
  **Type:** <code>{"null | "}[Image](/simulang-js/api/v14.0.0/classes/Image){"[]"}</code>
</ResponseField>

#### Returns

`string`

### askJson()

```typescript
askJson(prompt: string, text: undefined | null | string, images: undefined | null | Image[], schema: any): any
```

Ask the model for one JSON value that matches `schema`.

Same `prompt`, `text`, and `images` as \[`AskModel.ask`]. `schema` is a
JSON Schema document. A caller that has it as text parses it before
calling. The request sends that document unchanged. `"answer"` is
only the name the chat API requires on the schema; it is not a key
in the reply. One call carries one schema.

The schema is compiled locally before the request. The reply is
parsed and checked against that same schema. A reply that is not
JSON, or that does not match, throws. A document that is not valid
JSON Schema throws and no request is sent.

The provider is also asked for strict mode. The local check is what
decides whether the value is returned. `additionalProperties` and
`required` are sent exactly as the caller wrote them.

Throws and sends no request when this model does not support it.
\[`AskModel.jsonSchemaAliases`] lists the models that do.

#### Parameters

<ResponseField name={"prompt"} type={"string"} required />

<ResponseField name={"text"} type={"undefined | null | string"} required />

<ResponseField name={"images"} type={"undefined | null | Image[]"} required>
  **Type:** <code>{"undefined | null | "}[Image](/simulang-js/api/v14.0.0/classes/Image){"[]"}</code>
</ResponseField>

<ResponseField name={"schema"} type={"any"} required />

#### Returns

`any`

### availableAliases()

```typescript
availableAliases(): string[]
```

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()

```typescript
byAlias(alias: string): AskModel
```

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

<ResponseField name={"alias"} type={"string"} required />

#### Returns

<code>[AskModel](/simulang-js/api/v14.0.0/classes/AskModel)</code>

### checkAuth()

```typescript
checkAuth(): void
```

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:

```ts
try { model.checkAuth() } catch { process.exit(1) }
```

### default()

```typescript
default(): AskModel
```

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

<code>[AskModel](/simulang-js/api/v14.0.0/classes/AskModel)</code>

### jsonSchemaAliases()

```typescript
jsonSchemaAliases(): string[]
```

LLM aliases whose provider entry sets `json_schema` to true, using the
same auth filter and first-provider-wins rule as \[`AskModel.byAlias`].
\[`AskModel.availableAliases`] still lists every LLM, including models
that only serve \[`AskModel.ask`].

#### Returns

`string[]`
