Skip to content

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.

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.

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:create
  • ai-foundation:write:ai-connection:delete
  • ai-foundation:write:ai-connection:update
  • ai-foundation:write:lock-review-mark-reviewed
  • ai-foundation:write:refresh-models
  • ai-foundation:write:reset-models-on-platform-switch
  • Requires: config
  • Optional: tenant
  • Activation: always on (not toggleable)

Per-tenant config keys, set via the tenant-admin UI or a seed. 🔒 = encrypted at rest.

KeyTypeDefaultScopeWho can writeWho can read
default-effortselect (low | medium | high | xhigh | max)hightenantsystem, TenantAdmin, SystemAdminall
default-max-tokensnumber (256–200000)16000tenantsystem, TenantAdmin, SystemAdminall
image-connectiontext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
image-modeltext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
monthly-transcription-secondsnumber (≥ 1)—tenantsystem, TenantAdmin, SystemAdminall
platform-anthropic-api-keytext—system 🔒system, SystemAdminSystemAdmin
platform-anthropic-endpointtext""systemsystem, SystemAdminSystemAdmin
platform-monthly-speech-charactersnumber (≥ 1)500000systemsystem, SystemAdminSystemAdmin
platform-monthly-tokensnumber (≥ 1)2000000systemsystem, SystemAdminSystemAdmin
platform-monthly-transcription-secondsnumber (≥ 1)15000systemsystem, SystemAdminSystemAdmin
platform-openai-compat-api-keytext—system 🔒system, SystemAdminSystemAdmin
platform-openai-compat-endpointtext""systemsystem, SystemAdminSystemAdmin
platform-openrouter-api-keytext—system 🔒system, SystemAdminSystemAdmin
platform-openrouter-endpointtext""systemsystem, SystemAdminSystemAdmin
speech-connectiontext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
speech-modeltext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
speech-voicetext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
text-connectiontext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
text-modeltext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
transcription-connectiontext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User
transcription-modeltext""tenantsystem, TenantAdmin, SystemAdminTenantAdmin, SystemAdmin, User