AI

LLM gateway for other modules: one set of DSL library functions (complete, chat, chatWithFile, extract) that call Anthropic or OpenAI-compatible APIs with the keys, model and limits a tenant configures once, here.

Try it in your workspacefree workspace · you confirm before anything installs

v0.1.2 · 6 installs · free

What it does

AI is the one place where a workspace connects to a language model. It has no screens, tables or buttons of its own. Instead it gives other modules a small set of functions for asking a model a question, sending it a file, or getting structured data back. Provider, model, limits and API key are set once here, so no other module carries a vendor name or a key.

An admin installs it, adds an API key and, if wanted, changes a few settings. Modules that use it, such as File Library, then work without further setup.


Highlights

  • Two providers — Anthropic and OpenAI. Any server that speaks the OpenAI chat API (Azure OpenAI, Ollama, vLLM, a proxy) works through the base URL setting.
  • Keys stay in secrets — the Anthropic and OpenAI keys are secrets on this module, never settings, and appear by name on the Admin Secrets page.
  • Files as input — send a PDF or a PNG, JPEG, GIF or WebP image along with the question.
  • Structured answers — extract asks for JSON and returns it parsed.
  • Failures you can store — chat, chatWithFile and extract never throw. They return ok, error and token usage, so a calling action can write a status on the record instead of rolling back.
  • Readiness check — configError() tells a caller up front whether the key, provider and model are in place.
  • Per-folder tuning — every setting can differ by folder, for example a stronger model for one department.
  • Per-call overrides — a caller can override provider, model, token limit, temperature or system prompt for one call.

Functions

Function Returns Notes
complete(prompt, options?) text Shortest form. Ends the run with an error on failure
chat(messages, options?) result messages is a string or a list of { role, content }
chatWithFile(prompt, file, options?) result file is the value of a file field
extract(prompt, schema?, options?) result with parsed data Asks for JSON only and strips a code fence
configError(options?) message or null Missing key, unknown provider or empty model
isConfigured(options?) true or false Same check as a flag

A result is { ok, text, data, error, provider, model, stopReason, usage: { inputTokens, outputTokens }, raw }. Options are provider, model, maxTokens, temperature, system, baseUrl and json.

execute:
	var r = ai.chatWithFile('Summarize this file in two paragraphs.', [file])
	if (r.ok) {
		[summary] = r.text
	} else {
		[processing_error] = r.error
	}

A module calls these after listing the functions it needs in its own deps/ai.json.

Setup

  1. Install the module.
  2. In Admin > Secrets, set anthropic_api_key or openai_api_key, matching the provider.
  3. Optionally change the provider, model and limits in the module settings.

Limits

Calls run under the action budget: 10 calls per script, 120 seconds per call, 5 MB per response, and 10 MB per file sent to the model. Long or many calls belong in a background action, as File Library's Summarize does.

How it fits

File Library uses it for file summaries.

Used by

Published modules that build on this one.

AI
Try it
/ explore more

Browse the full
module catalog.

Every module is metadata — install it in one click, then change anything.