Skip to content
Menu

AI Integration

View .md

Beacon uses one configured LLM provider for every AI feature. This page covers what Beacon uses the provider for and what reaches it; full provider configuration for a host is in Integrate → AI.

The AI layer lives in the Beacon.AI package. A host turns it on in two places:

var beacon = builder.Services.AddBeaconServices(builder.Configuration, options =>
{
options.UseAI = true; // default false
});
builder.Services.AddBeaconAI(builder.Configuration);

With UseAI off (the default), Beacon registers stand-ins for the AI-backed services it needs elsewhere, so the host starts and the non-AI features work; Test connection and the eval harness report that AI is unavailable.

ProviderProvider valueAdmin Settings cardWhat it needs
OpenAIOpenAIOpenAIAPI key, model
AnthropicClaudeAnthropicAPI key, model
Azure OpenAIAzureOpenAIAzure OpenAIEndpoint (your resource), API key, deployment name as the model
AWS BedrockBedrockAWS BedrockRegion, model id, AWS credentials; needs Moberg.Beacon.AI.Bedrock + AddBeaconBedrock()

The model is the string you enter: Beacon does not restrict or recommend model ids. OpenAI and Anthropic are called on their public API endpoints; there is no base-URL or proxy setting for them. Azure OpenAI uses your resource’s endpoint, and Bedrock your AWS region, so you choose where requests go.

For Bedrock, the authentication mode decides the credentials: the IAM role mode (the default) uses the host’s default AWS credentials (an IAM role, environment variables), the access key mode an access key id and secret access key, and the temporary credentials mode those keys with a session token. An ApiKey that holds a pair as accessKey:secretKey, from an older install, is still used when the key fields are empty; in the IAM role mode a warning is logged when it is (see Admin Settings).

An Admin configures the provider at runtime in Admin Settings (/beacon/admin-settings), section AI provider: pick a provider card, fill in the fields it shows, use Test connection, then Save changes. Only an Admin changes the connection (provider, endpoint, region, credentials) and the concurrency and per-minute limits; a SecurityAdmin can change the models and the other settings and test the stored connection. Secrets are stored encrypted. The REST routes are GET /beacon/api/admin-settings (Auditor or SecurityAdmin), PUT /beacon/api/admin-settings and POST /beacon/api/admin-settings/test-llm (SecurityAdmin). See Admin Settings.

A save swaps the provider in place: every caller injects ILlmProvider, registered as DelegatingLlmProvider, which forwards to the provider LlmProviderManager currently holds. When the new configuration cannot build a provider, the manager keeps the previous one and logs a warning.

The Beacon:LLM section (Provider = OpenAI, Claude, AzureOpenAI or Bedrock; ApiKey, Endpoint, Region, SessionToken, Model, FastModel, Limits) is described key by key in Integrate → AI. Never put a provider key in source or a committed appsettings.json.

Every LLM call goes through LlmRequestQueue. It allows at most Limits:MaxConcurrentRequests calls at once (default 50; a value saved under Max concurrent requests in Admin Settings applies without a restart, and a lower one never cancels a running call); background work holds at most half of them. A call that finds no free slot within Limits:InteractiveQueueWaitSeconds (60; background work Limits:BackgroundQueueWaitSeconds, 300; at most an hour), or arrives while Limits:MaxQueuedRequests (200) interactive calls, or half as many background calls, already wait, fails with LlmQueueSaturatedException (“The LLM is busy. Try again later.”). For Claude and Bedrock the queue is the only retry layer: a transient failure (rate limit, overload, unavailable, timeout, connection failure) is tried up to three times, waiting at least what Retry-After asks (up to 60 seconds), with a slot held only while an attempt runs; a call that still fails surfaces as LlmTransientException (an AiServiceException). OpenAI and Azure OpenAI retry themselves and the queue does not retry them again: a status they stopped retrying surfaces as an HttpRequestException carrying it, a connection failure or timeout as an AiServiceException. See Integrate → AI. Tokens and requests per minute under Rate limits & budget on the Admin Settings page apply only while Enforce requests/tokens per minute is on (off by default; 0 is unlimited); the monthly budget is recorded, not enforced. The Fast model serves the short classification calls on the ask path (intent classification and data-source routing); when it is empty, equals the main model, cannot be built or fails when called, they use the main model.

FeatureWhere it is described
The MCP ask tool and knowledge answers: routing, SQL generation and repairMCP Server
The learning loop’s lesson extraction, the optional eval judge and contextual-retrieval blurbsKnowledge Base & Grounding
Project documentationbelow
AI actorsAI Actors

Local embeddings for semantic search do not use the LLM provider: they run in-process from an ONNX model (see Local embeddings).

Beacon generates documentation per project, from the metadata of the data sources the project links and the code references found in its repositories. Generation runs as a background task that follows its requester (see below). The result has these sections: Project Overview, Business Domains, Data Model, Data Flows, Code Lineage, Data Quality, API Documentation (for API data sources) and Glossary.

ActionRouteNeeds
Read the latest documentation and its historyGET /beacon/api/projects/{id}/documentationRead in the project
Generate or regenerate (background task, 202 with { taskId, jobId, state })POST /beacon/api/projects/{id}/documentation-generationsCurate in the project
Read a generation’s progress (state: 0 queued, 1 running, 2 succeeded, 3 failed, 4 skipped; failureCode says why)GET /beacon/api/projects/{id}/documentation-generations/{taskId}Read in the project
Generate or regenerate (5.0 route, kept; answers with the job id)POST /beacon/api/projects/{id}/generate-documentationCurate in the project
Edit a sectionPUT /beacon/api/projects/documentation-sections/{id}Curate in the project
Ask the LLM to rewrite a section (returns the new text, saves nothing)POST /beacon/api/projects/documentation-sections/{id}/instructQuery in the project
Export as Markdown, or HTML with asHtml=trueGET /beacon/api/projects/documentation/{id}/exportRead in the project

Curate is held by project admin members and Admins (see Who curates grounding). In the UI, the Documentation tab of a project (/beacon/projects/{id}) shows the latest documentation, lets anyone who may read it download it as Markdown or HTML, and lets a curator generate it, edit its sections, or ask the LLM to change a section (the proposed text is shown and saved only after a confirmation).

A generation runs as the user who started it: right before the first LLM call it checks again that they may still curate the project and query its data sources (a live Admin may), and is skipped (forbidden) if not. Only one generation of a project is queued or running at a time (429 otherwise). A host whose scheduler implements EnqueueBackgroundTask runs it in its job runner; without one it runs in the request.

Curated sections. A section a person changed, by editing it or by applying a documentation patch to it, records who changed it (Users.Id) and when (editedTime in the API) and is marked Curated in the UI. Regenerating keeps it: the new documentation takes the latest documentation’s curated sections in place of what the run generated for their type, still marked curated, so regeneration never replaces curated text with fresh LLM output. A section that failed to generate holds a fixed “Generation failed for this section” text, never the provider’s error. Each finished generation is recorded in the security audit as curation.documentation_generated.

The documentation is also grounding: it is chunked, optionally embedded, and retrieved when an agent asks a question over MCP, so a better table description improves generated SQL (see Documentation chunking).

Column values. Generation lists distinct values of enum-like columns only while sample-value collection is on for the project and every project sharing the data source (off by default), never from PII or secret-like columns, and never under the deployment lock Beacon:Mcp:ForbidRowDataToLlm. Each prompt that carries such values is logged as event 7123.

A prompt carries the question, schema (table and column names, types, descriptions, join paths) and your curated knowledge (documentation, glossary, verified examples, learned patterns). Row data (sample values, value matches, discovered column values, eval-judge rows, database errors) is off by default or screened, and every prompt that carries it is logged as event 7123 (RowDataSentToLlm, category Beacon.AI.Services.LlmProviders.LlmRowDataEgress) with identifiers only. The full table, and the lock Beacon:Mcp:ForbidRowDataToLlm that keeps all row data from the provider, are in What reaches the LLM provider.

Everything Beacon sends about a data source is read through the caller’s authorized project: schema context, documentation, code references, glossary, golden examples, learned patterns and value matches. The AI services take that project as a parameter (projectId on IKnowledgeGraphService and IValueGroundingService), read a data source only through a project that links it, and never mix in another project’s material from a shared data source. See Project isolation.

Beacon records token counts and estimated cost where a feature stores them: AI actor think cycles and plans (and the actor’s totals). Documentation generation records no cost. Use your provider’s own usage reporting for billing.

“No active LLM provider” on Admin Settings. No provider has been saved in Admin Settings yet. Pick a provider, test it and save.

AI calls fail after a restart although Admin Settings looks right. The provider was built from Beacon:LLM at startup, which logs a warning when it cannot build one (for example Azure OpenAI without Endpoint, Bedrock without Region). Save Admin Settings again, and bring Beacon:LLM in step.

Test connection fails. Check the key, the model or deployment name, and for Azure OpenAI the endpoint. For Bedrock, check the region, the model id and that the host’s AWS credentials may invoke the model.

Test connection reports that AI is unavailable. The host did not set UseAI = true or did not call AddBeaconAI.

Calls fail after retries. Rate-limit and transient errors are tried up to four times on OpenAI and Azure OpenAI and three times on Claude and Bedrock; persistent failures usually mean the provider’s own quota. Lower Max concurrent requests in Admin Settings, or turn on Enforce requests/tokens per minute with the provider’s quota, or raise the quota with the provider.

Calls fail with “The LLM is busy. Try again later.” Every slot stayed taken for the whole wait limit, or too many calls were already waiting, or the enforced requests or tokens per minute left no room within the wait. Retry later, or raise Max concurrent requests or the per-minute limits (within the provider’s quota), or the Limits:*QueueWaitSeconds / Limits:MaxQueuedRequests limits and restart.

Debug logging. Raise the log level for the AI namespaces:

{
"Logging": {
"LogLevel": {
"Beacon.AI.Services.LlmProviders": "Debug",
"Beacon.AI.Services.Ai": "Debug",
"Beacon.AI.Services.Documentation": "Debug"
}
}
}