ai-foundation
Enterprise Part of the commercial Kumiko Enterprise offering — not in the open framework.
Plugin host and connection store that wires an LLM (and optionally a transcription and a speech) provider to your app without coupling it to a specific vendor SDK. A tenant keeps its AI connections here (anthropic, openai, openai-compatible; the API key is a write-only, encrypted field) and assigns them to jobs in the standard models (text, images, dictation, read-aloud). Add it when you want features like ai-patch, ai-generate, or ai-triage; each of those calls createLLMProviderForTenant(ctx, tenantId) from this package to resolve the provider at request time; transcription uses createTranscribeProviderForTenant, read-aloud createSpeechProviderForTenant. A SystemAdmin can provide platform connections (one key per vendor) that every tenant may pick, and sets the monthly limits (text and images, dictation, read-aloud) a tenant gets on them; an app’s budget resolvers override those per tier, and a tenant can only lower its dictation limit. Calls on the platform key are metered, so cap-counter must be mounted. Adapters (ai-provider-anthropic, ai-provider-openai-compat) only build the provider; credentials and endpoints are resolved here. The AI calls screen (ai-foundation:screen:ai-calls, TenantAdmin, SystemAdmin and the roles in aiCalls.readerRoles) lists every model call of the tenant with tokens and cost; aiCalls.costs: "hidden" drops the costs and aiCalls.handlerLabels names the app’s handlers. The readiness system check gets the probes ai-connections, ai-standard-models, ai-platform-connections and the paid ai-extract-test-invoice.
Build it yourself
Section titled “Build it yourself”This Enterprise implementation is optional. If you need a narrower or domain-specific version, you can build an app-owned feature, handler, or job with Kumiko’s public extension points.
Use this package when you want the maintained implementation, its existing contracts, and the surrounding operational behavior. A custom implementation is not drop-in compatible automatically: your app owns its authorization, validation, integrations, tests, security review, and production operations.
Start with Features and composition and Custom write handlers.
How it fits
Section titled “How it fits”What this feature needs to run (Requires, top) and the write commands this feature provides (Provides, bottom).
flowchart TB
n_ai_foundation["ai-foundation"]
subgraph how_reqs["Requires / optional"]
n_config["config"]
n_tenant["tenant"]
end
subgraph how_provides["Provides"]
n_cmd_ai_foundation_write_ai_connection_create(["create"])
n_cmd_ai_foundation_write_ai_connection_delete(["delete"])
n_cmd_ai_foundation_write_ai_connection_update(["update"])
n_cmd_ai_foundation_write_lock_review_mark_reviewed(["lock-review-mark-reviewed"])
n_cmd_ai_foundation_write_refresh_models(["refresh-models"])
n_cmd_ai_foundation_write_reset_models_on_platform_switch(["reset-models-on-platform-switch"])
end
n_config --> n_ai_foundation
n_tenant -.->|optional| n_ai_foundation
n_ai_foundation --> n_cmd_ai_foundation_write_ai_connection_create
n_ai_foundation --> n_cmd_ai_foundation_write_ai_connection_delete
n_ai_foundation --> n_cmd_ai_foundation_write_ai_connection_update
n_ai_foundation --> n_cmd_ai_foundation_write_lock_review_mark_reviewed
n_ai_foundation --> n_cmd_ai_foundation_write_refresh_models
n_ai_foundation --> n_cmd_ai_foundation_write_reset_models_on_platform_switch
Provides — write commands this feature registers (dispatch them through the command bus):
ai-foundation:write:ai-connection:createai-foundation:write:ai-connection:deleteai-foundation:write:ai-connection:updateai-foundation:write:lock-review-mark-reviewedai-foundation:write:refresh-modelsai-foundation:write:reset-models-on-platform-switch
Dependencies
Section titled “Dependencies”Configuration
Section titled “Configuration”Per-tenant config keys, set via the tenant-admin UI or a seed. 🔒 = encrypted at rest.
| Key | Type | Default | Scope | Who can write | Who can read |
|---|---|---|---|---|---|
default-effort | select (low | medium | high | xhigh | max) | high | tenant | system, TenantAdmin, SystemAdmin | all |
default-max-tokens | number (256–200000) | 16000 | tenant | system, TenantAdmin, SystemAdmin | all |
image-connection | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
image-model | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
monthly-transcription-seconds | number (≥ 1) | — | tenant | system, TenantAdmin, SystemAdmin | all |
platform-anthropic-api-key | text | — | system 🔒 | system, SystemAdmin | SystemAdmin |
platform-anthropic-endpoint | text | "" | system | system, SystemAdmin | SystemAdmin |
platform-monthly-speech-characters | number (≥ 1) | 500000 | system | system, SystemAdmin | SystemAdmin |
platform-monthly-tokens | number (≥ 1) | 2000000 | system | system, SystemAdmin | SystemAdmin |
platform-monthly-transcription-seconds | number (≥ 1) | 15000 | system | system, SystemAdmin | SystemAdmin |
platform-openai-compat-api-key | text | — | system 🔒 | system, SystemAdmin | SystemAdmin |
platform-openai-compat-endpoint | text | "" | system | system, SystemAdmin | SystemAdmin |
platform-openrouter-api-key | text | — | system 🔒 | system, SystemAdmin | SystemAdmin |
platform-openrouter-endpoint | text | "" | system | system, SystemAdmin | SystemAdmin |
speech-connection | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
speech-model | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
speech-voice | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
text-connection | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
text-model | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
transcription-connection | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |
transcription-model | text | "" | tenant | system, TenantAdmin, SystemAdmin | TenantAdmin, SystemAdmin, User |