ai-ui

ai-ui

CI Docs Release Go License: MIT GHCR

A small, self-hosted ChatGPT-like web interface written in Go with document context (RAG), connected to Azure OpenAI-compatible deployments, with an optional identity-backed Microsoft Foundry deployment inventory.

Current release: 1.6.1. Settings now shows compact deployment choices and expandable connection checks, with technical connection details and the full inventory collapsed by default. Errors remain visible. FLUX's expected missing-prompt HTTP 422 is recognized as a limited API probe, not an inference failure or proof of generation access. Saved model selections are unchanged. See the release notes and upgrade checklist.

Website with the full screenshot gallery: https://daknoblo.github.io/ai-ui/

Screenshots

Chat with Markdown answers

Documents as context (RAG) Image generation Token statistics
Documents as chat context Image generation Token statistics

All screenshots are generated automatically from the demo instance (cmd/demo) - see Demo & documentation.

Features

Architecture

Configuration

Variable Default Description
AZURE_RESOURCE_ID – Optional. Anchors legacy chat/vision/embedding selections and discovers accessible accounts in its resource group. Group-level Reader is required for sibling discovery; see Foundry inventory & identity.
AZURE_IMAGE_RESOURCE_ID primary resource Optional in Foundry mode. Anchors legacy image selections and additionally discovers its resource group with the same service principal. Requires AZURE_RESOURCE_ID, group Reader and inference permissions on enabled accounts; see Separate image resource.
AZURE_TENANT_ID – Tenant ID of the service principal; required in Foundry mode.
AZURE_CLIENT_ID – Application/client ID of the service principal; required in Foundry mode.
AZURE_CLIENT_SECRET – Secret. Service-principal secret; required in Foundry mode, environment only.
AZURE_API_KEY – Secret. AI endpoint key in manual mode; not required or used for Foundry identity authentication.
AZURE_EMBEDDING_API_KEY – Secret, manual mode. Required for an embedding endpoint with a different scheme or host. Empty ⇒ AZURE_API_KEY is used only for the same origin.
AZURE_IMAGE_API_KEY – Secret, optional, manual mode. Dedicated image endpoint key. Empty ⇒ AZURE_API_KEY is used.
SEARCH_API_KEY – Secret, optional. API key for web search (Tavily or Brave). Not required for SearXNG.
DATA_DIR /appdata Persistent data path. The SQLite database is stored directly in it, the UI settings in <DATA_DIR>/appdata/config.json.
PORT 8080 HTTP port.
HEALTHCHECK_INTERVAL 60s Interval of the periodic connection check (Go duration, e.g. 30s, 2m). 0 or off disables the periodic check (the start-up check still runs).
TZ – IANA time zone name. The binary bundles time/tzdata, so this works in the distroless image.

Remaining settings are configured in the UI dialog and stored in <DATA_DIR>/appdata/config.json (without secrets). The general AI endpoint and the embeddings can use separate endpoints, deployments and API versions in manual mode; empty embedding fields fall back to the values of the AI endpoint. When AZURE_RESOURCE_ID is absent, this existing API-key/manual mode is retained. Setting a resource ID without a valid identity does not fall back to API keys.

Two endpoint schemas are detected automatically: the classic Azure OpenAI format (https://<resource>.openai.azure.com, deployment in the path, api-version required) and the new OpenAI compatible v1 format of Azure AI Foundry, recognizable by the /openai/v1 path (https://<resource>.services.ai.azure.com/openai/v1). With the v1 format the deployment is passed as model in the request and api-version is optional. The chat and embedding endpoints may use different schemas in manual mode.

Foundry inventory & identity (optional)

For an installation outside Azure, provide these four environment settings for an existing service principal and one existing Foundry/Azure OpenAI account:

AZURE_RESOURCE_ID, AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET. For a new installation, follow the service-principal setup below.

Inject the real secret through your deployment environment or secret manager, not through config.json or committed files. The resource ID only opts in; it does not authenticate the application by itself. The endpoint is derived from valid account metadata returned by Azure Resource Manager (ARM). AZURE_ENDPOINT is an optional explicit OpenAI-compatible /openai/v1 endpoint override, for example when metadata does not provide a usable endpoint. Thus the basic automatic-endpoint setup needs four settings. Add AZURE_IMAGE_RESOURCE_ID when image deployments live in another account; no additional identity or secret is needed. Endpoint overrides remain optional. The distroless image remains a single static, non-root Go binary: it contains no Azure CLI and requires no interactive login.

Have an administrator assign Cognitive Services OpenAI User, scoped to that one resource, as a starting role. Verify that the identity has the required account/deployment metadata read permissions and the data-plane permissions for the operations you will use. Some model types or operations, including image operations, may need additional operation-specific permissions; this role is not a promise that every Foundry model or protocol is usable. Inventory visibility alone does not prove inference permission. The app never grants roles.

Refresh deployments reads ARM metadata for the configured accounts and automatically discovers other OpenAI/AI Services accounts in the same resource groups as AZURE_RESOURCE_ID and, when set, AZURE_IMAGE_RESOURCE_ID. This uses the ARM accounts-by-resource-group API, not a subscription-wide scan. Assign the service principal Reader at each resource-group scope, in addition to the model-specific inference permissions on each account you intend to use. A resource-scoped OpenAI role alone does not grant group listing. Reader exposes metadata; it does not grant inference or permission to read account keys. These permissions must be granted by an administrator; the application never modifies Azure resources or role assignments.

If group listing is denied, the configured accounts and last successful inventories remain available, with an explicit Reader/access warning. A failing account is reported separately rather than erasing healthy accounts. Discovery uses bounded pagination, timeouts and same-scope validation; bearer credentials are never forwarded to arbitrary pagination hosts. Sibling accounts are read with at most four concurrent discovery workers per group, so one slow account does not block all healthy siblings. Metadata GETs retry transient request timeouts and retryable HTTP responses up to three attempts within the existing 45-second group deadline. These retries do not replay image generation or edits.

With no separate image resource, it also reads /openai/v1/models?api-version=preview on the same inference endpoint for known GPT-Image model IDs. With a separate image resource, only actual ARM deployments from the discovered accounts populate the image picker; neither account's Models API is queried. Discovery does not scan subscriptions, read account keys, create deployments or provision resources. A data-plane model list alone is insufficient to establish chat/embedding deployment capabilities. The inventory classifies canonical model name, version, format, provisioning state, SKU and available capabilities, not guesses based on an arbitrary deployment alias. Unsupported models, native Anthropic deployments and batch-only deployments remain visible with a reason, but cannot be used by the pickers. The current client routes OpenAI-compatible chat completions, embeddings, image generation and image edits; discovery is not universal Foundry protocol support.

The inventory groups chat, embeddings, and image models and shows their capabilities, version, format, and source. Models API image entries can be available by name without appearing as ARM deployments. Provider aliases are preferred over duplicate dated image variants, and an ARM deployment always wins a name collision. Listing a model proves neither that it is deployed in that resource nor that generation is permitted. An image deployment in another resource must be discovered through one of the configured resource groups, not inferred from a matching catalog model ID. AZURE_IMAGE_RESOURCE_ID also allows an explicit image account in a different group or subscription. If the image catalog cannot be read, the ARM inventory still updates and any previous image entries for the same resource/endpoint are retained with a warning.

Enabled deployments and cyclic routing

Settings provides separate checkbox pools for chat, vision/OCR, image generation, image edits, and embeddings. Each choice identifies the deployment, resource, Azure region, canonical model and version. A deployment name such as gpt-image-2 in Sweden and the same name in Poland are distinct selections, keyed internally by resource ID plus deployment name.

Sunburst and a compact image-model selection

gpt-image-2.5-sunburst (OpenAI, version 2026-09-08) supports image generation and editing. It has independent resolution and quality controls, including xhigh and max. Those values are never sent to FLUX or older GPT image models. Resolution presets include square, portrait and landscape up to 2560x1440 (or 1440x2560); experimental larger resolutions are not exposed. Higher quality/resolution can increase latency and cost.

For a compact choice of Sunburst + FLUX.2 Pro:

  1. Deploy Sunburst on the desired image resources and refresh the inventory.
  2. In both Image generation and Image edits, enable the Sunburst and FLUX.2 Pro replicas, and disable GPT-Image-2, FLUX.2 Flex and other models.
  3. Save. The composer then offers Automatic plus these two canonical models, not one entry per region. Explicit selection cycles only matching replicas; Automatic cycles the complete enabled pool.
  4. Switch existing chats explicitly pinned to disabled image models to one of the remaining models. They do not silently change model.

Discovery and upgrades do not automatically replace saved selections. Keep old deployments as a rollback until generation and cross-region editing are verified, then remove them separately if desired. Existing images/documents remain stored; no embedding reindex is required. Flare is not added by this feature; previously supported image models remain available when enabled.

FLUX.2 image models

Deploy FLUX.2-pro and/or FLUX.2-flex (BlackForestLabs format, version 1) on a supported Azure AI Services / Foundry resource. Refresh the inventory, then explicitly activate the desired regional deployments in Image generation and Image edits and save. Discovery alone never enables a deployment. Existing GPT-Image deployments and manual API-key mode remain supported.

The image-model selector above the chat input is saved per chat and never changes the text-chat model. In Foundry mode, Automatic cycles the entire enabled image pool, including GPT-Image and FLUX; selecting a model cycles only that canonical model's enabled regional replicas. It also applies when a chat uses the image tool. In manual mode, Automatic uses the configured image default.

FLUX inference permissions: Cognitive Services OpenAI User alone does not authorize the BFL provider API. For the application service principal, use a custom role with the following DataActions, assigned only at each image resource that it needs to call:

The MaaS permission covers image generation with an optional base image, but alone is insufficient for the BFL route: Azure also requires the provider action for POST /providers/{providerName}/*. The provider action is not FLUX-specific or image-only; it permits provider model actions on the assigned resource. Keep assignments resource-scoped and approve this broader inference access explicitly. The role needs no key-listing or management permissions; broader Foundry User or Cognitive Services User roles are not required. Keep the separate Reader permission needed for ARM inventory discovery.

If an existing installation reports PermissionDenied naming AIServices/providers/action, update its custom role, allow time for Azure RBAC propagation, and retry generation. This permission fix does not require a new application image.

Use the operation name from Microsoft.Authorization/providerOperations with $expand=resourceTypes. The CognitiveServices operations API may advertise Microsoft.CognitiveServices/accounts/AIServices/images/generations, but that alias is not a valid RBAC DataAction and role creation rejects it with InvalidDataActionOrNotDataAction. Successful deployment provisioning or a check under an operator identity does not establish the application's inference access. Authorization failures remain explicit errors; the application does not switch models or retry another replica to hide them.

FLUX.2 uses the BFL provider API, not OpenAI's images API: /providers/blackforestlabs/v1/flux-2-pro?api-version=preview or /providers/blackforestlabs/v1/flux-2-flex?api-version=preview, on that resource's trusted AI Services/BFL host. If ARM prefers an OpenAI hostname for chat, its separately advertised same-resource AI Services/BFL endpoint is retained for FLUX; hosts are never guessed from a deployment alias. Refresh older cached inventories before using FLUX. The deployment alias is sent as model. Reference images are sent inline as input_image; editing uses the latest successful image (or latest upload), never the output of a failed attempt.

The Azure adapter consumes the synchronous data[0].b64_json response used by the official Foundry FLUX sample. It caps response size, rejects redirects and non-image payloads, and does not fetch response image or polling URLs. BFL's direct public asynchronous API is a different service and is not supported. A URL-only or asynchronous response is an explicit failure rather than an outbound download or credential forwarding. See Microsoft's FLUX documentation for model availability and the provider request schema.

The supported-model mapping includes GPT chat models, model router, OpenAI text embeddings, GPT-Image and Black Forest Labs FLUX.2 generation/editing. DALL-E image options and Cohere embedding request formats need separate adapters and are not selectable in Foundry mode. New chat model names can use recognized Azure chat/vision capability metadata when their model format is already supported. Known model profiles cover deployments that omit those hints, including GPT-5.6, GPT-6 Astra, GPT-6.2 Astra, GPT-chat-latest and Grok 4.3. Unsupported protocols, Responses-only models and batch deployments remain excluded.

Automatic image requests use a function tool routed through the enabled image generation/edit pool (or the legacy configured deployment), not a model chosen by the chat response. GPT-6 Astra, GPT-6.2 Astra and GPT-5.5/5.6 use the Responses API for tool-enabled turns; requests are stateless (store=false), and encrypted reasoning items are retained only within the current tool loop. Other supported chat models use Chat Completions tools. The selected text model and conversation mode are not changed by image delegation. The chat deployment must support function tools on its selected API. The manual image button bypasses chat-model orchestration and remains available.

In Settings, use Refresh, check the deployments for each operation, Save, then run Check again. Refresh fetches metadata only: it neither invokes models nor changes enabled selections. A failed refresh keeps the last successful inventory and displays the failure. Connection verification is separate and can consume chat/embedding tokens.

Legacy chat, vision and embedding selections stay on the primary account; legacy image selections stay on AZURE_IMAGE_RESOURCE_ID when set, otherwise the primary account. Checkbox pools can use compatible deployments from any discovered account. Endpoint overrides constrain their operation to the matching discovered endpoint, and environment deployment overrides pin its original account. Remove those overrides to enable multi-resource routing for that operation. Separate-resource API-key configurations remain available in manual mode. AZURE_MODELS and AZURE_IMAGE_MODELS, when supplied in Foundry mode, restrict the discovered supported choices; they cannot turn an unsupported or undiscovered deployment into a supported one. The settings dialog warns when these environment filters hide compatible deployments. Remove obsolete filters if you want to select from the complete discovered inventory.

Service-principal setup and operation

Open Azure Cloud Shell in Bash mode in the tenant that owns your Foundry resource. Your user needs permission to create app registrations/service principals and assign roles on that resource. Replace the three placeholders and run:

az account set --subscription '<subscription-id>' &&
RESOURCE_ID="$(az cognitiveservices account show \
  --resource-group '<resource-group>' \
  --name '<foundry-account-name>' \
  --query id --output tsv)" &&
test -n "$RESOURCE_ID" &&
az ad sp create-for-rbac \
  --name "ai-ui-$(date -u +%Y%m%d-%H%M%S)" \
  --role 'Cognitive Services OpenAI User' \
  --scopes "$RESOURCE_ID" \
  --years 1 \
  --output json &&
printf 'AZURE_RESOURCE_ID=%s\n' "$RESOURCE_ID"

This creates an app/service principal with a timestamped name, grants access only to that Foundry account, and creates a secret valid for one year (subject to tenant policy). The account name is the Azure resource name, not a Foundry project name. The && chain stops on errors.

Copy the output into your container's environment settings:

Output value Container variable
Printed AZURE_RESOURCE_ID AZURE_RESOURCE_ID
JSON tenant AZURE_TENANT_ID
JSON appId AZURE_CLIENT_ID
JSON password AZURE_CLIENT_SECRET

Copy and securely store password immediately; Azure does not let you read its value again. Do not commit or share the output, or put the secret in Compose YAML or config.json. If you change the generated name, use an unused name: create-for-rbac can modify an existing app with a matching display name. This is a one-time creation command, not a container startup or rotation command.

docker-compose.example.yml already maps these four variables. Start/recreate the container with the values, then open Settings > Refresh deployments, select the models, Save, and Check again. Allow a few minutes for new role assignments to propagate; model verification and use can incur Azure charges.

Before expiry, add a new secret to the same app, update the container's environment and recreate it. Remove the old secret only after testing the new one; retain the data volume. See the Azure CLI service-principal guide for details.

Separate image resource

If the image deployment belongs to a different Foundry/Azure OpenAI account, set AZURE_IMAGE_RESOURCE_ID to that account's ARM resource ID. Keep AZURE_RESOURCE_ID and the existing tenant/client/secret settings unchanged. The accounts may be in different resource groups or subscriptions, but must be accessible to the same service principal in the same Entra tenant. The app does not search projects or entire subscriptions automatically; discovery is limited to the resource groups of these explicit account IDs.

In Cloud Shell Bash, signed into that tenant, grant the existing service principal access to the image account. Replace the placeholders; the caller needs permission to read the account/service principal and create role assignments at the image resource scope:

IMAGE_SUBSCRIPTION='<image-subscription-id>' &&
IMAGE_RESOURCE_ID="$(az cognitiveservices account show \
  --subscription "$IMAGE_SUBSCRIPTION" \
  --resource-group '<image-resource-group>' \
  --name '<image-account-name>' --query id --output tsv)" &&
SP_OBJECT_ID="$(az ad sp show \
  --id '<existing-AZURE_CLIENT_ID>' --query id --output tsv)" &&
test -n "$IMAGE_RESOURCE_ID" && test -n "$SP_OBJECT_ID" &&
az role assignment create \
  --subscription "$IMAGE_SUBSCRIPTION" \
  --assignee-object-id "$SP_OBJECT_ID" \
  --assignee-principal-type ServicePrincipal \
  --role 'Cognitive Services OpenAI User' \
  --scope "$IMAGE_RESOURCE_ID" --output none &&
printf 'AZURE_IMAGE_RESOURCE_ID=%s\n' "$IMAGE_RESOURCE_ID"

This adds resource-scoped permissions only. Also assign Reader on its resource group for automatic sibling-account discovery. It neither creates a service principal nor creates/rotates a secret. A Cloud Shell login-cache error needs to be resolved in that shell; it does not by itself mean the app's service principal credentials are invalid.

Add the printed variable to the container environment and recreate it. Leave AZURE_IMAGE_ENDPOINT unset to derive the endpoint from the image account; remove an old override that points to the primary resource. In Settings, choose Refresh deployments, check the actual image deployments for generation and editing, save, then Check again. Allow time for role assignments to propagate. AZURE_IMAGE_DEPLOYMENT can optionally pin that deployment, and AZURE_IMAGE_MODELS remains an optional allow-list for that image resource.

The configured image account has its own cached ARM inventory, read-only resource/endpoint fields and connection-check row. Refresh attempts both accounts even if one fails, retains each last successful cache separately, and never falls back to the primary endpoint when the image account is unavailable. Metadata updates are reflected immediately in the displayed inventory checks without silently repeating inference probes. Chat/embedding readiness and the stored embedding profile are not reset by an image-only inventory change; changing just the image resource does not require rebuilding embeddings.

Switching the embedding model

Every index records its endpoint, deployment, API version (for classic endpoints) and vector dimensions. Foundry indexes additionally record the resource and canonical model/version. This applies to both identity-backed Foundry and manual/API-key configuration. Saving a different embedding default does not relabel or mix existing vectors. A legacy corpus with no known embedding profile also needs an explicit rebuild before it can be used safely. An older classic-endpoint profile without a recorded API version likewise requires rebuilding with an explicitly configured version.

Compatible Foundry replicas can share an index without reindexing. All checked embedding deployments must identify exactly the same known canonical model, model version and dimensions. The app does not infer compatibility from equal dimensions alone, deployment aliases or arbitrary manual endpoint names. Incompatible checkbox combinations are rejected with a localized error before settings or the active index change. Legacy endpoint-bound profiles retain their source provenance; known matching model/version/dimensions permit routing to a live, explicitly enabled replica. Query, ingestion and reindex batches all use the index's vector-space profile and validate response dimensions. Persisted profiles never authorize destinations or credentials on their own.

Manual/API-key endpoints with unknown metadata remain endpoint/deployment/API- version bound; no cross-endpoint vector compatibility is assumed. Disabling the embedding pool disables embedding requests, including use of an existing index. Changing to a different vector space still requires the staged rebuild below; the old index continues using its known source until the atomic switch, when that source is still present and authorized.

Save the new embedding selection, review the document/chunk counts and cost warning, then explicitly consent to Rebuild embedding index in Settings. Rebuilding embeds the stored chunk texts into a staged index; it does not reparse the original files or repeat OCR. It can process the whole corpus and incur embedding API charges, so consider its size and your provider's current pricing before confirming. No monetary estimate is guessed by the app.

Progress is shown in the dialog. Corpus mutations such as uploads and document/chat deletion are temporarily blocked while the rebuild runs. Only a complete successful rebuild becomes active; failure leaves the previous index intact. The old profile remains separate from the newly selected default until the switch succeeds, rather than silently querying old vectors with a new model.

Manual embeddings can inherit the chat API key only when the endpoints have the same scheme and host. A separate origin requires AZURE_EMBEDDING_API_KEY. Previously configured embedding endpoints remain authorized for the old index during the current process. After a restart, only the current configuration authorizes a destination: a persisted profile alone cannot send the current key to an old endpoint. If those settings are incompatible, retrieval fails explicitly until you restore the matching configuration or complete a rebuild. Switching between manual and Foundry authentication also requires rebuilding; existing vectors are never relabeled.

The Rebuild options section also permits an explicitly confirmed rebuild of the current profile, for example to repair an index or regenerate changed vector dimensions. Out-of-band deployment changes are detected when inventory metadata is refreshed; refresh after changing deployments in Azure.

Several deployments, one configuration (manual mode)

All deployments of a resource share its endpoint and API key. AZURE_MODELS declares the available chat deployments for verification and automatic vision fallback. Existing chat pins and saved model defaults remain in effect; otherwise new chats use the first list entry, or AZURE_DEPLOYMENT when the list is empty. There is no model selector in the chat header. With the v1 schema the resolved name is sent as model; with the classic schema it becomes the deployment in the request path.

Embeddings and image generation are separate APIs and therefore keep their own deployment setting, but they can live in the same resource: leave their endpoint empty and only name the deployment.

Language

The interface language (English or German) is selected in the settings dialog and applies to the whole application, including the prompts used for the automatic chat titles and the document/web context. The page reloads once after the language has been changed. New installations default to English.

Temperature & reasoning effort

The temperature lives in the settings dialog under Behavior and applies to every chat request. The reasoning effort (the reasoning_effort parameter of reasoning models) is chosen per chat next to the input field; the settings dialog only holds the default for new chats.

The offered values follow the conversation's configured model; deployment defaults are managed in Settings, not in a chat-header selector. GPT-6 offers low, medium, high, xhigh; GPT-5.x profiles offer none, low, medium, high, xhigh; GPT-5 offers minimal, low, medium, high; reasoning-capable o-series models offer low, medium, high. Models without reasoning hide the field. auto omits the parameter so the model keeps its own default, and values outside the configured model's supported set are normalized to auto.

Pinning the endpoint via environment variables (optional)

In manual mode the endpoint settings can be provided entirely through environment variables instead of the UI dialog. When one of these variables is set, its value takes precedence over config.json and the matching field in the settings dialog is shown but disabled (not editable through the UI):

The naming scheme is consistent: the general AI endpoint uses the base names AZURE_*, the embeddings consistently use AZURE_EMBEDDING_*.

General AI endpoint:

Variable Setting
AZURE_ENDPOINT Endpoint URL of the AI endpoint. In Foundry mode, an optional explicit override of the discovered endpoint.
AZURE_DEPLOYMENT Deployment name of the chat model.
AZURE_MODELS Selectable models (comma or newline separated), e.g. model-router,gpt-5.1,o4-mini. In manual mode this is the source of the list, shown read-only; its entries are deployment names of the same resource. In Foundry mode it is an optional allow-list intersected with supported inventory entries.
AZURE_API_VERSION API version of the AI endpoint. Only used by the classic schema; with a /openai/v1 endpoint the client picks it and the field disappears from the settings dialog.

Embeddings (fall back to the AI endpoint when empty):

Variable Setting
AZURE_EMBEDDING_ENDPOINT Embedding endpoint URL.
AZURE_EMBEDDING_DEPLOYMENT Deployment name of the embedding model.
AZURE_EMBEDDING_API_VERSION Embedding API version.

Image generation (fall back to the AI endpoint when empty):

Variable Setting
AZURE_IMAGE_ENDPOINT Image endpoint URL, e.g. https://my-resource.services.ai.azure.com/openai/v1.
AZURE_IMAGE_DEPLOYMENT Deployment name of the image model, e.g. gpt-image-2.
AZURE_IMAGE_MODELS Image deployment list (comma or newline separated). In manual mode, empty ⇒ only AZURE_IMAGE_DEPLOYMENT; in Foundry mode, empty ⇒ supported inventory entries, otherwise an allow-list for the image selection in Settings.
AZURE_DOCUMENT_ENDPOINT Optional Document Intelligence S0 resource endpoint, e.g. https://my-documents.cognitiveservices.azure.com. Enables Layout for every PDF and TIFF/BMP/HEIF document upload.
AZURE_DOCUMENT_API_KEY Optional dedicated Document Intelligence key, environment only. When absent, uses the explicit AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET identity. No CLI/default-credential fallback in production.
AZURE_IMAGE_API_VERSION Image API version.

The key is AZURE_IMAGE_API_KEY; when it is empty AZURE_API_KEY is used. A dedicated key is required as soon as the image endpoint belongs to a different resource - the chat key is rejected there with HTTP 401. The settings dialog points that out, and the connection check probes the image deployments as well with an intentionally incomplete validation request rather than generating an image. Size, quality and file format are chosen in the settings dialog.

The matching secrets are AZURE_API_KEY and AZURE_EMBEDDING_API_KEY respectively (see the table above).

Variables that are not set stay editable in the UI. Empty values count as "not set" and do not lock anything.

Readiness & connection check

Settings prioritizes the selectable deployment pools. Checkbox rows show the deployment name, resource and region; full identifiers/model versions remain available under Details. Connection addresses and the full inventory are collapsed by default to avoid repeating the same metadata. Check results use compact expandable rows. Errors stay expanded, while limited metadata/API probes are labeled as such rather than shown as proof of inference. Refresh only updates inventory; Save applies checkbox selections; Check again tests saved settings and may consume chat/embedding tokens.

The connection check sits at the top of the settings dialog and runs at startup. In manual mode it also runs in the dialog after configuration changes; in Foundry mode save the role selections and explicitly choose Check again. It probes storage (data path writable), chat and embeddings, and the selectable chat deployments individually. A typo in a manual AZURE_MODELS list or an inference permission error therefore appears before that model is picked. Refresh in Foundry mode is a separate metadata-only operation. Checks use the saved settings and name the model being tested. Unconfigured optional features and checks not run by the periodic monitor are shown as skipped, not as failures. Cached inventory checks are labeled as metadata. The vision check verifies the chat route, not image understanding. The image check sends no prompt: only the expected missing-prompt response is accepted, and the result explicitly says that generation is untested. An arbitrary 400, such as unknown_model, is an error, not a green check. Use a real image request when you want to verify generation, bearing in mind the associated charges. For FLUX, a structured HTTP 422 error containing only a missing body.prompt is also an expected probe result. Other 422 errors remain failures; this probe still does not prove permission to generate an image.

Document uploads are only enabled once storage and the embedding endpoint are green, because a document is chunked and embedded on the way in. Attaching an PNG/JPEG/WebP/GIF image needs neither: it is stored as is and travels with the message. With AZURE_DOCUMENT_ENDPOINT, PDFs and TIFF/BMP/HEIF document images use Azure Document Intelligence and require its analysis permissions, not a vision deployment. Without it, a scanned PDF needs a supported vision deployment (a vision-capable AZURE_MODELS entry in manual mode, or the selected chat/vision role in Foundry mode); without one the upload fails with that reason instead of storing an empty document. That legacy fallback recognizes only directly embedded JPEG/PNG scans; it is not a general PDF renderer. A background check (HEALTHCHECK_INTERVAL) monitors the connection continuously - without the per-deployment probes - and reports failures through the sidebar status and the log.

Office imports preserve missing Excel columns and workbook tab order, associate PowerPoint notes with their actual slides, and retain text in nested Word tables. RTF imports decode UTF-16 surrogate pairs and scoped Unicode fallbacks. Malformed selected Office parts and resource-limit violations fail the upload instead of silently returning an incomplete extract. Each Office archive is limited to 64 MiB per part, 128 MiB total inflated data, 256 MiB processing work, 2,000 entries/part reads, two million XML tokens, nesting depth 256 and 8 MiB extracted text.

Parser improvements apply to newly uploaded documents. To replace an old incorrect extract, remove and upload that document again; rebuilding embeddings alone reuses the already stored text.

Azure Document Intelligence (optional)

Set AZURE_DOCUMENT_ENDPOINT to a dedicated S0 resource's custom-domain endpoint and reuse the app's explicit Azure service-principal environment:

environment:
  - AZURE_DOCUMENT_ENDPOINT=https://my-documents.cognitiveservices.azure.com
  - AZURE_TENANT_ID=${AZURE_TENANT_ID}
  - AZURE_CLIENT_ID=${AZURE_CLIENT_ID}
  - AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET}

Alternatively, supply AZURE_DOCUMENT_API_KEY for that resource. No secret is stored in the UI or configuration file. Invalid/incomplete startup configuration fails explicitly. The integration uses prebuilt-layout, API 2024-11-30, without optional paid add-ons or custom model training.

Grant a custom role only at this resource, with no management/key actions:

Microsoft.CognitiveServices/accounts/FormRecognizer/documentmodels:analyze/action
Microsoft.CognitiveServices/accounts/FormRecognizer/documentmodels/analyzeresults/read

These grant document-model analysis/results, not an exclusive restriction to Layout. Provisioning or testing with an operator identity does not establish the app identity's effective access. Verify a synthetic PDF upload using the deployed app identity, including result deletion, before using real documents. The existing connection monitor does not make billable Layout probes.

Processing and formats

Limits and failure behavior

Uploads remain limited to 25 MiB/file. Azure analysis accepts up to 100 pages, with a five-minute deadline and one concurrent analysis per app process. When the local PDF parser can determine the page count, over-limit documents are rejected before submission. Otherwise the request includes pages 1-101: the sentinel page detects over-limit files, so up to 101 pages may be billed even when the upload is rejected. Longer documents are never silently truncated. Use S0, not F0 (which returns only two pages). Known PDF page counts are checked against the result; unreadable local page counts cannot detect an F0 truncation, making the S0 requirement essential.

Responses are capped at 32 MiB and extracted text at 8 MiB. Missing/out-of-order pages, invalid page spans, empty output, service errors and cleanup failures fail the upload instead of indexing a partial result. The legacy vision OCR fallback also aborts on a failed page. Malformed files and OCR mistakes are not made reliable by automatic retries.

Billable POST submissions are never automatically replayed. Polling respects bounded Retry-After delays; redirects and cross-origin operation URLs are rejected before forwarding credentials. The app attempts to delete the Azure analysis result after retrieval or failure, including request cancellation. If cleanup fails, the upload reports failure; Azure's retention policy can still apply. Original files are not added to local document storage; extracted chunks stay in the existing SQLite database.

Costs and privacy

Layout includes OCR and is charged per analyzed page; embeddings and chat usage remain separate. Only explicitly enabling this endpoint sends PDFs and the additional document-image formats to Document Intelligence. Microsoft documents regional processing and temporary retention of inputs/results for 24 hours, with earlier deletion through the result-deletion API. See pricing and data handling.

After enabling the feature, upload previously failed/incomplete PDFs again. An embedding reindex cannot recreate text that was never extracted. For comparing documents, retrieval still selects relevant excerpts rather than guaranteeing a complete line-by-line audit of every page.

An opt-in integration test uses synthetic text and scanned PDF pages:

DOCUMENTAI_LIVE_TEST_ENDPOINT=https://my-documents.cognitiveservices.azure.com \
DOCUMENTAI_LIVE_TEST_SUBSCRIPTION=<subscription-id> \
go test ./internal/documentai -run '^TestLiveLayout$' -v -count=1

This makes one billed two-page Layout request using the Azure CLI operator identity, not the production service principal. Normal tests use local fixtures and never contact Azure. To test the application identity instead, set DOCUMENTAI_LIVE_TEST_AUTH=application and supply the three AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET environment variables; this mode never falls back to CLI credentials.

Web search (optional)

Pick a provider in the settings dialog under Web search:

When a provider is configured, a 🌐 toggle appears next to the chat input. While it is active, the message is enriched with current web results; the state survives switching chats. The search API key is - like the Azure keys - read exclusively from the SEARCH_API_KEY environment variable and never stored in config.json.

The SearXNG base URL is fetched by the server, so it is validated: only http/https URLs are accepted, and connections to loopback and link-local addresses (including the cloud metadata service 169.254.169.254) are refused. Private LAN ranges stay reachable because that is where a self-hosted instance usually lives.

Security

Running locally

Sending a message creates a durable generation tied to that exact message. SSE connections observe or replay it; reconnecting or reloading does not start another provider request. Each chat accepts one active generation at a time, with at most four chat/image generations across the application. Additional submissions receive an explicit busy response without storing a message or starting a provider request; they are not automatically queued or retried. Closing the browser does not cancel that generation, which has a ten-minute timeout. Application shutdown cancels and joins active workers; after a restart, interrupted operations are marked as such and are never automatically retried because the provider may already have processed them. Optional title generation has a separate fifteen-second timeout.

The conversation scrolls along with new output while you remain at the bottom. Scroll upward to read earlier lines without being pulled back down by incoming text, tool notices or unrelated settings updates. A floating Jump to latest button shows whether output is still running, reconnecting, or finished. Finishing does not move your reading position; a connection error is not treated as completion. Click the button or scroll back to the bottom to resume following. Sending a new message or opening another conversation starts at the latest output again. The same behavior applies on desktop and mobile.

Copying messages

Copy and Retry use matching, borderless labeled icon buttons on the right of the footer of every input and output throughout the conversation, not just the latest answer. Token usage and the actual model stay on the left of assistant footers, using the same font and size as the actions. On narrow screens the actions wrap onto the next line and remain right-aligned. Copy copies only the selected message body, not the model name, tool notices or token usage. Inputs can be copied immediately, even during generation; assistant answers can be copied once their stream finishes. Both actions remain available throughout reopened and older conversations. Rich HTML and plain text are supplied together, so the target application can use the format it supports. Headings, emphasis, lists, tables and code structure are retained; the target editor controls the final appearance. Successful formatted copying does not display a confirmation message.

Clipboard access generally works best over HTTPS or localhost. If the browser does not support rich clipboard access, the app attempts a user-initiated copy fallback. A plain-text-only result or a denied clipboard operation is reported explicitly, not shown as a successful formatted copy. The complete answer is copied, including text outside the visible viewport. Images themselves are not copied as image files; their available alternative text is included instead.

Sending a previous question again

The labeled Retry button beside Copy sends a previous question as a new user message at the end of the current chat, just like entering it in the composer again. On an input it sends that input; on an assistant answer it sends the question belonging to that answer, not the answer text. The new user message and a new answer are appended; existing messages are never overwritten. A confirmation warns about additional API charges. Failed and interrupted attempts can also be retried.

The current conversation history, including later questions and answers, is used. Model and reasoning settings, composer chat/image mode, web-search and image-edit toggles, image parameters and available attachments are read again. In image-edit mode this uses the current latest image, exactly like a new submission. This intentionally differs from the former retry behavior that reused saved options and the original history boundary. Automatic tool selection and document/web retrieval are performed again. A draft in the composer is not sent or overwritten by Retry.

Only one attempt may run per chat, subject to the application-wide generation limit. Retry controls are disabled during active generation; the backend also rejects overlapping requests. Reconnecting to an accepted retry only observes that job and does not create another attempt. Older conversations without saved generation metadata use the user question preceding the selected answer. Previously generated retry answers retain their explicit original-question link, even when newer questions appear before them. Only answers with no associated user question have an unavailable Retry action; copying still works.

The model reported by the provider appears beside the token/input/output figures below the answer, not as a separate badge beside the assistant heading. Both use the same font, size and color. Recorded model and usage metadata also remain visible when reopening a conversation; missing historical metadata is not replaced with a guessed current model.

Organizing chats

On desktop, drag the right edge of the sidebar to adjust its width. The width is saved in the current browser and bounded so the conversation remains usable. Double-click the edge to restore the default. The focused resize handle also supports Left/Right arrows, Home/End and Enter to reset; Escape cancels a drag. The mobile navigation drawer keeps its existing width.

The sidebar has New chat and New group actions side by side. Give a group a name and optionally choose a color; its conversations appear indented under an expandable heading. Groups have one level, not nested subgroups. Use the group menu to rename it, change its color or remove it. Successful group updates do not display a confirmation message; errors remain visible.

Drag a conversation onto a group, including a collapsed group, to move it. The Move chat action provides the same operation without dragging for keyboard and touch users. Move a chat into Ungrouped to remove its group assignment. Moving a chat only updates the sidebar: it does not interrupt the current response or replace the conversation you are reading.

Groups are shown in creation order and their chats retain the usual most-recently-updated ordering. New chats start ungrouped. Group metadata, assignments and collapse state are stored in SQLite and survive restarts. Removing a group keeps all its conversations under Ungrouped; it does not delete their messages, documents or images. Empty chats explicitly organized into groups are preserved rather than treated as abandoned new-chat entries. Chat grouping is organizational, not an access-control or privacy boundary.

Stored images

Generated and uploaded images are stored as binary data in the SQLite database under the persistent data path, with their chat association and metadata. Successful generated images are committed together with their assistant reply. They survive container recreation when the same data volume is retained. Deleting a chat also deletes its associated images. Back up the database/data volume to retain them. There is currently no separate media library in the navigation; view images in their conversations and use the browser's image save action to download them.

Static asset URLs carry content versions. Opening settings also updates the page's stylesheet, so a page left open during a container update does not render new controls with old CSS.

export AZURE_API_KEY=your-key
DATA_DIR=./data PORT=8080 go run .
# http://localhost:8080

Docker

docker build -t ai-ui .
docker run --rm -p 8080:8080 \
  -e AZURE_API_KEY=your-key \
  -v ai-ui-data:/appdata \
  ai-ui

Data path permissions (non-root)

The container runs as a non-root user (UID/GID 65532) and stores all data (chats, documents, embeddings, configuration) under /appdata. A Docker managed named volume is used as persistent storage:

services:
  ai-ui:
    image: ghcr.io/daknoblo/ai-ui:latest
    volumes:
      - ai-ui-data:/appdata
volumes:
  ai-ui-data:

A freshly created named volume inherits its ownership from the image (65532) and therefore works out of the box - including in Dockge/Portainer as a normal user, without any manual permission handling. Docker manages the volume; no changes on the host are required.

Deployment

docker-compose.example.yml contains one ai-ui container with a named volume and the published port 8080; Traefik labels are included but commented out. The project is designed for exactly one container - how many instances of it you run is up to you (e.g. several services in a single stack). The image is built and published to ghcr.io/daknoblo/ai-ui by GitHub Actions. Main builds update latest and stable; version releases publish tags such as 1.6.1 and 1.6 and also advance latest. Use an exact version or digest for controlled upgrades. The image tag carries no v prefix even though the git tag does.

Upgrading to 1.6.1

Version 1.6.1 simplifies Settings and corrects the FLUX missing-prompt probe. Update the container and fully reload the browser. Run Check again to replace previously cached FLUX probe errors. Existing checkbox selections, model routing and document data are unchanged; no reindex is needed.

Version 1.6.0 adds Sunburst image generation/editing and independent options. Back up the volume, update the image and reload the browser. Refresh the inventory and follow the compact image selection checklist to keep only Sunburst and FLUX.2 Pro in both image pools. Existing model choices are not silently changed, and old deployments are not deleted by an upgrade. No database migration or embedding reindex is needed.

Version 1.5.2 fixes tool API selection and reasoning controls for gpt-6.2-astra (version 2026-11-17), including custom deployment aliases. After updating, refresh the Foundry inventory and explicitly enable the new deployments in the Chat and Vision/OCR pools, then save. Newly discovered models remain disabled until selected. Enable only the desired replicas if every new routed turn should use Astra 6.2; an explicitly pinned existing chat keeps its original model, so use a new chat to test round-robin selection. Reasoning options are auto, low, medium, high and xhigh. No embedding reindex or database migration is required.

Claude is still unsupported by the current OpenAI adapter. A model appearing in the Azure catalog with free quota does not establish Marketplace purchase eligibility: internal/sandbox subscriptions can reject paid Claude offers. Do not substitute another hosting version or subscription without approval.

Version 1.5.1 updates dependencies without changing the database schema. Back up the persistent volume, update the image and reload the browser. Keep the existing Azure endpoints, identity and Document Intelligence settings. No embedding reindex or deployment refresh is needed. A synthetic database created by 1.5.0 was opened with the new SQLite driver, migrated, written to and read back without changes to its existing chats, messages, documents, chunks or images.

Version 1.5.0 adds optional Azure document analysis and local OpenDocument extraction. Back up the data volume, update the image and reload the browser. Without AZURE_DOCUMENT_ENDPOINT, existing PDF extraction remains local with the limited vision-scan fallback. To enable Layout, configure an S0 resource, resource-scoped analysis permissions and the environment described in Azure Document Intelligence. No database migration or embedding reindex is needed. Remove and upload any previously failed/incomplete documents again; reindexing alone cannot recover missing text.

Version 1.4.2 unifies the composer layout across chat and image mode and adds the application name to browser tabs without changing model routing, image parameters or database schema. From 1.4.0/1.4.1, update the container and fully reload the browser. No deployment refresh, selection changes or embedding reindex is needed for these UI fixes.

Version 1.4.0 adds FLUX.2 image generation/editing and the image-model selector and settings above the composer. Existing chats, documents, configuration and deployment selections are retained. Upgrading from 1.3.0 does not require an embedding reindex or new credentials for existing GPT-Image usage. Enabling FLUX requires the resource-scoped inference permission described in FLUX.2 image models.

For a two-region FLUX setup, refresh the inventory after upgrading, explicitly enable all four deployments (Pro and Flex in each region) in both Image generation and Image edits, then save the pools. Refresh alone does not activate them. Choose Automatic or a specific image model above the chat input; PNG/JPEG, resolution/aspect ratio and Flex steps/guidance apply to the selected model family. This image-only change does not require reindexing documents.

When updating an existing 1.2.x installation, back up the data volume, update the image and fully reload the browser. For older installations, the group and generation-link migrations introduced in the 1.2 series run automatically. The compatibility notes below also apply to those upgrades. The 1.2, 1.3, 1.4 and 1.5 image tags stay on their respective release series; switch explicitly to 1.6.1 or 1.6 to follow the new series. For multi-resource discovery, grant the app identity Reader on the configured resource groups while keeping inference permissions scoped to the intended accounts. Refresh deployments, explicitly enable the desired targets and save the checkbox pools. Newly discovered targets are not enabled automatically. Compatible embedding replicas do not require a rebuild; changing the embedding model or vector space still requires the explicit staged reindex workflow. Existing chats with explicit model pins keep those pins; use a new chat to test round-robin chat selection.

Retry now sends the associated question as a new user message at the end of the current chat, including its current history, composer settings and attachments. It does not replace an old answer or replay the original saved request options. Existing assistant-only retries from rolling builds retain their original question association. See Sending a previous question again.

  1. Back up the complete data volume before upgrading. Stop ai-ui while copying /appdata, or use a consistent SQLite backup procedure. Retain the database, any journal/WAL files, stored configuration and file ownership. Do not remove the volume or run docker compose down -v.

  2. Pin the image in the existing stack to ghcr.io/daknoblo/ai-ui:1.6.1, keeping the same persistent volume, ports and environment settings. The 1.6 tag follows releases in this minor series; an exact version or digest is preferable when upgrades must be controlled.

  3. Review the configuration changes below, then recreate the ai-ui service. With the service name from the example:

    docker compose pull ai-ui
    docker compose up -d --no-deps ai-ui
    
  4. Reload the browser, open Settings and verify the saved configuration. In Foundry mode, refresh deployments before checking the selected models. Storage migrations run automatically; the app does not automatically regenerate existing embeddings or retry interrupted generation requests.

  5. Test a normal chat and document retrieval. If images are configured, check their resource/deployment and then test generation separately if desired; a real image request incurs provider charges. The incomplete image connection probe does not generate an image.

Important compatibility and behavior changes:

For rollback, stop the new container and restore the pre-upgrade data backup together with the previous pinned image. Merely pointing an older binary at a database already migrated by a newer version is not a supported rollback procedure.

Development

gofmt -l .                  # must print nothing
go vet ./...
golangci-lint run ./...
go test -race ./...
CGO_ENABLED=0 go build ./...

User interface strings live in internal/i18n. Every key must exist in all supported languages; a test enforces that.

Automated regression coverage

CI runs the full Go race suite and the browser regression suite on every pull request and push to main, including dependency-only changes. The release workflow reuses that CI gate, so browser failures also block image publication. The browser matrix covers English and German on desktop and mobile using isolated, credential-free demo data.

Area Automated coverage
Foundry discovery Transient timeout retries, cancellation, bounded account concurrency, slow-account isolation and cached inventory retention
Deployment pools Resource-qualified identities, concurrent round-robin, frozen per-turn routes, checkbox persistence and explicit disablement
Embeddings Compatible replicas, vector-space validation, index provenance and atomic staged reindexing
Images Latest successful image across repeated edits, resource rotation, failures and retry; FLUX model selection and settings; no automatic inference replay
Conversation actions Copy/retry throughout history, formatted clipboard and fallback/error paths, unchanged prior answers/drafts, model/token footer alignment
Navigation Chat groups, move/collapse actions, resizable sidebar persistence, keyboard controls, mobile layout and streaming scroll behavior

Run the browser checks without regenerating or deleting screenshots:

CGO_ENABLED=0 go build -o bin/ai-ui-demo ./cmd/demo
cd tools/screenshots
npm ci
npx playwright install chromium
node capture.mjs --bin=../../bin/ai-ui-demo --checks-only

Use --langs=en or --langs=de for a focused run. The default runs all 32 check groups across both languages and layouts. Failures exit nonzero; demo processes and temporary databases are cleaned up. Actual Azure permissions, regional availability and paid inference are not exercised by these fixtures.

Demo & documentation

The repository contains a demo instance that needs neither an API key nor any Azure resources: internal/demo provides a stub of the Azure-compatible endpoints (chat streaming, embeddings, images) and seeds the database with conversations, documents, a generated image and token statistics. The legacy manual demo remains available. -foundry opts into the new inventory using a fake identity and loopback-only v1 endpoints, never an Azure credential or resource. Aliases such as chat-primary, docs-primary and canvas map to canonical GPT-4o, text-embedding-3-large and gpt-image-1 metadata; native and batch-only examples are visible but unusable. Refresh, role defaults and reindexing operate on the local fixture.

go run ./cmd/demo -data ./data/demo                        # Manual demo
go run ./cmd/demo -foundry -data ./data/demo-foundry        # Foundry demo
go run ./cmd/demo -foundry -data ./data/demo-foundry-de -lang de
go run ./cmd/demo -foundry -separate-images -data ./data/demo-images
# http://localhost:8080

Use separate data paths for the two modes, or -reset to discard a previous demo fixture. Embeddings are deterministic hashed demo vectors, not real model output. The Foundry fixture initializes its profile through the same staged reindex workflow over stored texts, rather than relabeling legacy vectors. A second local embedding alias lets you try the consent and rebuild flow without API costs. Web search remains a display-only placeholder in the demo.

The -separate-images option adds a second loopback backend and a separate image account with actual GPT-Image 2/1.5 deployment metadata, using the same fake identity. The original primary resource and embedding profile stay intact.

The demo is also the source of the screenshots. The capture script starts it with -foundry -separate-images, exercises both local inventories, role defaults and reindex consent views, and captures those sections with Playwright. The resource and endpoint remain truthful read-only demo values; it does not replace them with real Azure URLs or contact real services. The gallery contains 37 screenshots, including the FLUX image controls in English and German. Screenshots are written to docs/screenshots, together with a manifest describing every shot:

CGO_ENABLED=0 go build -o bin/ai-ui-demo ./cmd/demo
cd tools/screenshots && npm ci && npx playwright install chromium
node capture.mjs --bin=../../bin/ai-ui-demo --out=../../docs/screenshots

cmd/site turns this README and the screenshots into the static website that is published on GitHub Pages:

go run ./cmd/site -out site   # open site/index.html

The Docs workflow runs all three steps on every push to main that touches the application, the templates or this README: it recaptures the screenshots, commits them when they changed and deploys the regenerated website. New features therefore appear in the documentation without a manual screenshot session.

License

Released under the MIT License.