Skip to content

Enabling AI

This page is for administrators. It explains how to switch the AI assistant on for your CosMO site, decide what it is allowed to do, and give the right people access. Once you have done this, each user connects their own AI provider on their own settings page — see Setting Up Your AI Provider.

Who can do this

Only the Administrator role can change AI settings or assign the AI User role. See User Roles & Permissions.


Step 1 — Turn AI on for the site

  1. Open the settings (gear) menu and choose AI. (This screen is only available to administrators.)
  2. Switch to the Settings tab.
  3. Turn on Enable AI globally.
  4. Click Save.

That is the master switch. While it is off, nobody can use the assistant — no matter what roles they hold. You can turn it off again at any time to immediately disable AI across the whole site (no restart needed).


Step 2 — Choose what the assistant may do

On the same Settings tab you control how the assistant is allowed to work:

Setting Default What it does
Internal MCP (chat tool calls) On Lets the assistant look up your projects, benchmarks, and cost data to answer questions. With this off, the assistant still chats, but cannot see any CosMO data — answers are general only.
External MCP (X-API-KEY clients) Off Lets outside AI applications (for example Claude Desktop, Claude Code, or Cursor) connect to CosMO with an API key and read data through the same tools. Leave off unless you specifically want this.

Tip

For the normal in-app chat experience, leave Internal MCP on and External MCP off. The external option is an advanced, opt-in integration.


Step 3 — (Optional) Restrict which providers users may use

By default, users may point CosMO at any AI provider endpoint they like. If you want to limit this — for example, to allow only your organisation's approved provider, or only an internal model server — add an allow-list of permitted provider addresses.

In the Allowed provider addresses box on the Settings tab, enter one pattern per line. Each line is a regular expression matched against the full address a user enters. Lines beginning with # are comments.

# Only allow OpenAI and a local Ollama server
^https://api\.openai\.com/v1/?$
^http://localhost:11434/v1/?$
  • Leave the box empty to allow any provider (the default).
  • CosMO checks your patterns when you save and rejects an invalid expression with an error, so you cannot lock yourself out with a typo.
  • The allow-list applies when a user saves new provider settings. Existing configurations that no longer match keep working until the user next changes them.

Step 4 — Give people access

Even with AI switched on, a user can only chat if they hold the AI User role.

  1. From the settings (gear) menu, choose Users.
  2. Open the user you want to grant access to.
  3. Add the AI User role and save.

See User Roles & Permissions for the full description of roles. The change takes effect the next time the user signs in.

Both are required

A user needs AI switched on globally and the AI User role. Administrators do not get AI access automatically — an administrator who wants to use the chat must also hold the AI User role.


Monitoring usage

The Usage tab on the AI Usage screen shows how much the assistant is being used across your site — the number of requests, tokens consumed, and an estimated cost per user and per model. Use it to keep an eye on activity and spend.

Cost estimates are based on published per-model prices that ship with CosMO. If a provider changes its prices, or you use a model CosMO does not recognise, the token counts are still tracked but the cost figure may be missing or out of date. Administrators can update the price table in application.yml (see Advanced server settings).


Advanced server settings

The settings above cover everything most administrators need and are all changed from the AI Usage screen. The options below live in the server configuration file (application.yml) and require a restart to take effect. The defaults are sensible — change them only if you have a specific reason.

Rate limiting

To protect your provider account from runaway usage, CosMO limits how many AI requests each user can make per minute and per hour. The limits apply to everyone, including administrators.

cosmo:
  ai:
    rate-limit:
      enabled: true               # set false to disable the limit entirely
      requests-per-minute: 30
      requests-per-hour: 300
Audit log retention

Every AI interaction is recorded (who, when, how many tokens, estimated cost). By default these records are kept for one year and pruned nightly.

cosmo:
  ai:
    audit:
      retention-days: 365         # 0 = keep forever
      retention-cron: "0 0 3 * * *"   # prune daily at 03:00 server time
Token price table (for cost estimates)

The prices used on the Usage tab, in US dollars per million tokens. List more specific model names before more general ones, because the first match wins.

cosmo:
  ai:
    cost:
      token-rates:
        gpt-4o-mini:    { input-per-million: 0.15, output-per-million: 0.60 }
        gpt-4o:         { input-per-million: 2.50, output-per-million: 10.00 }
        claude-3-5-haiku:  { input-per-million: 0.80, output-per-million: 4.00 }
        claude-3-5-sonnet: { input-per-million: 3.00, output-per-million: 15.00 }
Custom system prompt

CosMO uses a built-in instruction prompt that tells the assistant how to behave. You can supply your own versions and select which is active. New conversations use the active version; existing conversations keep the version they started with.

cosmo:
  ai:
    prompt:
      active-version: ""          # blank = use the built-in prompt
      versions:
        # v1: |
        #   You are a cost analyst for our organisation...
Provider health polling

Optionally, CosMO can actively ping configured provider endpoints to flag a slow or unavailable provider before users notice. Off by default; provider health is updated from real chat traffic regardless.

cosmo:
  ai:
    health:
      enabled: false
      pingCron: "0 */5 * * * *"
      pingTimeoutMs: 5000