---
description: Connect a language-model provider so uploaded templates get an AI analysis — the two switches (enabled, automatic on upload), provider, model, endpoint and key, the timeout and the input and output limits that decide how much of a template the model sees, and cost notes.
---

# LLM analysis configuration

The **LLM Analysis Configuration** page (Admin section) sets up the AI provider behind
[template analysis](../custom-templates/template_editor_analysis.md#template-analysis) — the feature that
reviews an uploaded template and reports findings about problems and non-standard usage.

## The status card

Shows at a glance whether analysis is operational: **Status** (enabled/disabled),
**Provider**, **Model**, and whether a **Credential** (API key) is configured. Analysis
that is enabled but has no API key does not work — the page warns about exactly this
state.

## When analysis runs

Two switches at the top of the form decide that:

| Switch | Effect |
| --- | --- |
| **Template analysis** | Off: no AI analysis runs at all — the *Trigger AI Analysis* actions in the template list and on the analysis page are refused with *AI analysis is not enabled on this server*, and uploads are not analyzed. The static (non-AI) checks still run on every upload. |
| **Automatically analyze templates on upload** | On (and analysis enabled): every successful upload starts an AI run in the background right after it saves. Off: nothing runs by itself; someone opens the template's analysis page or its row menu and presses **Trigger AI Analysis** when they want a review. |

Manual-only is the cheaper setting for a library that changes often; automatic is the
safer one for a library where templates come from outside authors and nobody remembers to
press the button.

## Setting it up

1. Choose a **Provider**: OpenAI, Google Gemini, or Anthropic Claude. Choosing one fills
   in its **API Endpoint** and a default model.
2. Pick a **Model** — the field suggests known models for the chosen provider, and you can
   type any model identifier the provider supports (the hint links to the provider's model
   list).
3. Leave the **API Endpoint** as filled in unless you route requests through a proxy or a
   compatible self-hosted service.
4. Enter the provider **API key**. The key is stored encrypted on the server and never
   displayed back; once one is saved, leave the field blank to keep it or type a new value
   to replace it. If you change the **Provider** or **API Endpoint**, enter the key again in
   the same save: the server will not reuse the saved key with a different destination, so a
   blank key field is rejected with a prompt to re-enter it. If another administrator saved a
   different provider, endpoint or key while your save was being checked with the provider,
   your save is refused and nothing changes; reload the page to see their settings, then save
   again.
5. Switch **Template analysis** on, decide about automatic analysis, and save.

## Limits (Advanced)

These settings bound one analysis run. They matter because the model only ever sees what
fits inside them — a finding it did not report may simply be in a part of the template it
was not shown.

| Setting | Default | What it does |
| --- | --- | --- |
| **Timeout (ms)** | 300000 (5 minutes) | How long one request to the provider may take before the run is marked failed. The findings from the previous successful run are kept. |
| **Max files analyzed** | 3 | A cap on the number of files sent. The analysis only ever sends the authored root files, in this order: `index.html`, `styles.css`, `script.js`. At 3 all of them go; a lower value drops the later ones. Files under `assets/` are never sent, whatever this value. |
| **Max characters per file** | 40000 | Each file is cut at this many characters and marked `[TRUNCATED]` in the prompt, so a long `script.js` is reviewed only up to that point. Raise it for large templates — the provider charges per token sent. |
| **Max output tokens** | 4000 | The budget for the model's answer. An insufficient budget does not shorten the report: the cut-off answer is empty or unreadable JSON, the run is marked failed, and the previous successful findings remain. Raise the budget and retry. |

Each run also sends the system's template documentation and the player runtime source as
context, so the template files are a fraction of the prompt; the limits above control the
part you can influence.

Costs come from your provider account: each analysis run sends the template contents plus
that context to the configured model. Smaller/cheaper models are usually sufficient — the
task is explanation, not generation.

## Related

- [Template Editor and analysis](../custom-templates/template_editor_analysis.md) — where analysis is used
