> For the complete documentation index, see [llms.txt](https://docs.aibrow.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aibrow.ai/api-reference/aibrow/languagemodel.md).

# LanguageModel

## Static Methods

### <mark style="background-color:red;">static</mark> availability

`static async availability(options) =>`  [`AIModelAvailability`](/api-reference/types/aimodelavailability.md)&#x20;

Get the availability of the on-device language model.

| Options (optional)                                                                                        |
| --------------------------------------------------------------------------------------------------------- |
| **options** `optional` [`LanguageModelCreateOptions`](/api-reference/types/languagemodelcreateoptions.md) |

Returns the availability

### <mark style="background-color:red;">static</mark> compatibility <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

`static async compatibility(options) =>`  [`AIModelCoreCompatibility`](/api-reference/types/aimodelcorecompatibility.md)&#x20;

Get the availability of the on-device language model.

| Options (optional)                                                                                        |
| --------------------------------------------------------------------------------------------------------- |
| **options** `optional` [`LanguageModelCreateOptions`](/api-reference/types/languagemodelcreateoptions.md) |

Returns the compatibility

### <mark style="background-color:red;">static</mark> create

`static async create(options) =>` [`LanguageModel`](/api-reference/aibrow/languagemodel.md)&#x20;

Creates a new embedding session

| Options (optional)                                                                                        |
| --------------------------------------------------------------------------------------------------------- |
| **options** `optional` [`LanguageModelCreateOptions`](/api-reference/types/languagemodelcreateoptions.md) |

Returns a new LanguageModel session that can be prompted with the pre-provided configuration

***

## Properties

### gpuEngine <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

[`AIModelGpuEngine`](/api-reference/types/aimodelgpuengine.md)&#x20;

### dtype <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

[`AIModelDtype`](/api-reference/types/aimodeldtype.md)&#x20;

### flashAttention <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

`boolean`

### contextSize

`number`&#x20;

### inputUsage

`number`&#x20;

### inputQuota

`number`&#x20;

### topK

`number`&#x20;

### topP <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

`number`&#x20;

### temperature

`number`&#x20;

### repeatPenalty <mark style="background-color:green;">extension</mark> <mark style="background-color:purple;">web</mark>

`number`&#x20;

***

## Methods

### prompt

`async (input, options) => string`

See [promptStreaming](#promptstreaming)

### promptStreaming

`(input, options) => ReadableStream`

This prompts the language model with a continuation of the conversation. Internally, the input is appended to the set of messages in the language model's context window. Older messages outside of the language model's context window are automatically discarded.

<table><thead><tr><th>Input</th></tr></thead><tbody><tr><td><p>Either a <code>string</code>, single prompt or array of prompts such as</p><pre class="language-javascript"><code class="lang-javascript">[
  { content: "The prompt content", role: "user" },
  { content: "The prompt content", role: "assistant" }
]
</code></pre></td></tr></tbody></table>

| Options (optional)                       |
| ---------------------------------------- |
| **signal** `optional AbortSignal`        |
| **responseConstrains** `optional object` |

Returns a readable stream that updates each time new tokens are available from the language model

### append

`async (input) =>` `void`

Appends a message to the conversation without prompting the model

| Input      |
| ---------- |
| A `string` |

### measureInputUsage

`async (input, options) =>` `number`

Measures the prompt usage of the input

| Input      |
| ---------- |
| A `string` |

| Options (optional)                |
| --------------------------------- |
| **signal** `optional AbortSignal` |

Returns prompt usage based on the input
