Skip to main content
LLM usage is optional and must be explicitly configured. You can maintain full control by running local models on your own systems through Ollama, LM Studio, or similar tools. No data is sent to external services unless you configure a cloud provider.

Supported providers

Sure supports two first-class LLM providers:
  • OpenAI (or any OpenAI-compatible endpoint, including Ollama, LM Studio, OpenRouter, Groq, Together AI, etc.)
  • Anthropic (native Claude support, including custom Anthropic-compatible endpoints such as Amazon Bedrock or Google Vertex)
Set the active provider with the LLM_PROVIDER environment variable (or the LLM Provider setting in the UI). It defaults to openai. The matching access token must be configured for the selected provider. Chat routing also honors the model name: requests with claude-* models are routed to the Anthropic provider, and other models to the OpenAI provider, when both are configured.

Configuration via settings

Configure AI settings through the web interface:
  1. Go to SettingsSelf-Hosting
  2. Scroll to the AI Provider section
The form contains the following fields, grouped by function: Provider & credentials
  • LLM Provideropenai or anthropic
  • Access Token — API key for the selected provider
  • URI Base — Custom endpoint URL (OpenAI-compatible providers only; leave blank for OpenAI)
  • Model — Model name (required for custom endpoints)
Behavior
  • JSON Mode — Output mode for structured responses: auto, strict, json_object, or none
  • Chat Response Timeout — Whole-turn watchdog in seconds (see Chat response timeout)
Token budget
  • Context Window — Total tokens the model accepts
  • Max Response Tokens — Tokens reserved for the model’s reply
  • Max Items Per Batch — Upper bound for auto-categorize and merchant detection batches
  1. Choose your LLM Provider (openai or anthropic)
  2. Configure the matching credentials and options:
OpenAI / OpenAI-compatible provider fields: Anthropic provider fields: Settings in the UI override environment variables. If an environment variable is set, the corresponding field is disabled in the UI.

Choosing a provider

Sure ships with two first-class LLM providers:
  • OpenAI (and OpenAI-compatible) — default. Works with OpenAI directly, Ollama, LM Studio, OpenRouter, Groq, and any other OpenAI-compatible endpoint.
  • Anthropic — native Claude support via the Messages API, including auto-categorization, merchant detection, and provider-merchant enhancement.
Select the active provider with the LLM_PROVIDER environment variable:

OpenAI compatible API

Sure supports any OpenAI-compatible API endpoint, giving you flexibility to use:
  • OpenAI - Direct access to GPT models
  • Ollama - Run models locally on your hardware
  • LM Studio - Local model hosting with a GUI
  • Google Gemini - Use Gemini models directly with a Gemini API key
  • OpenRouter - Access to multiple providers (Anthropic, Google, etc.)
  • Other providers - Groq, Together AI, Anyscale, Replicate, and more

OpenAI

Recommended models:
  • gpt-4.1 - Default, best balance of speed and quality
  • gpt-5 - Latest model, highest quality
  • gpt-4o-mini - Cheaper, good quality

Ollama (local)

Install and run Ollama:

LM Studio (local)

  1. Download from lmstudio.ai
  2. Download a model through the UI
  3. Start the local server
  4. Configure Sure:

Google Gemini

Gemini provides an OpenAI-compatible endpoint that works with a Gemini API key from Google AI Studio:
Recommended models:
  • gemini-2.5-flash - Fast and capable
  • gemini-2.5-pro - Higher quality, more thorough responses

OpenRouter

Access multiple providers through a single API:
Recommended models:
  • google/gemini-2.5-flash - Fast and capable
  • anthropic/claude-sonnet-4.5 - Excellent reasoning
  • anthropic/claude-haiku-4.5 - Fast and cost-effective

Anthropic

Sure can talk to Anthropic’s Messages API directly, with full chat (text + streaming + tool use) parity with the OpenAI provider.
Recommended models:
  • claude-sonnet-4-6 - Default, best balance of speed and quality
  • claude-haiku-4-5 - Fast and cost-effective

Custom Anthropic-compatible endpoints

Set ANTHROPIC_BASE_URL to route requests through Amazon Bedrock, Google Vertex, or any other Anthropic-compatible proxy. ANTHROPIC_MODEL is required when a custom base URL is set, because proxy providers use their own model-ID conventions (for example, Bedrock IDs like anthropic.claude-sonnet-4-5-20250929-v1:0).

Anthropic environment variables

Batch operations

Auto-categorization, merchant detection, and provider-merchant enhancement are implemented on Anthropic via forced tool calls: a single output tool whose input_schema mirrors the desired result, invoked with tool_choice: { type: "tool", disable_parallel_tool_use: true }. This guarantees schema-valid output without JSON-mode fallbacks. Each batch operation caps the number of items at 25 per request, matching the OpenAI provider. Requests above this limit are rejected with a clear error before they are sent.

Token budget

Sure applies a token budget to every outbound LLM call — chat history, auto-categorization, merchant detection, and PDF processing. The defaults are conservative (2048-token context window) so small-context local models like Ollama work out of the box. If you use a cloud provider or a larger-context local model, raise these values.

Configure via settings UI

  1. Go to SettingsSelf-Hosting
  2. Scroll to the AI Provider section
  3. Under Token Budget, configure:
    • Context Window — total tokens the model accepts (default: 2048)
    • Max Response Tokens — tokens reserved for the model’s reply (default: 512)
    • Max Items Per Batch — upper bound for auto-categorize and merchant detection batches (default: 25)

Configure via environment variables

Environment variables take precedence over the settings UI.
Large batches of transactions are automatically sliced to fit the configured context window. You no longer need to worry about the previous 25-item hard limit — it is now a soft default that adapts to your model’s capacity.

Responses API routing

Sure automatically routes chat requests to the OpenAI Responses API when using the official OpenAI endpoint, and falls back to the Chat Completions API for custom providers. You can override this behavior with the OPENAI_SUPPORTS_RESPONSES_ENDPOINT environment variable.

AI cache management

Sure caches AI-generated results (like auto-categorization and merchant detection) to avoid redundant API calls and costs.

What is the AI cache?

When AI rules process transactions, Sure stores:
  • Enrichment records - Which attributes were set by AI (category, merchant, etc.)
  • Attribute locks - Prevents rules from re-processing already-handled transactions
This caching means:
  • Transactions won’t be sent to the LLM repeatedly
  • Your API costs are minimized
  • Processing is faster on subsequent rule runs

When to reset the AI cache

You might want to reset the cache when:
  • Switching LLM models - Different models may produce better categorizations
  • Improving prompts - After system updates with better prompts
  • Fixing miscategorizations - When AI made systematic errors
  • Testing - During development or evaluation of AI features
Resetting the AI cache will cause all transactions to be re-processed by AI rules on the next run. This will incur API costs if using a cloud provider.

How to reset the AI cache

Via UI (recommended):
  1. Go to SettingsRules
  2. Click the menu button (three dots)
  3. Select Reset AI cache
  4. Confirm the action
The cache is cleared asynchronously in the background. You can monitor the reset’s progress and any errors in Settings → Debug by filtering for the ai_cache_reset category. Each run logs when the job is enqueued, when it starts, how many AI cache entries were removed (broken down by scope), and any records that could not be cleared. Automatic reset: The AI cache is automatically cleared for all users when the OpenAI model setting is changed. This ensures that the new model processes transactions fresh.

What happens when cache is reset

  • AI-locked attributes are unlocked - Transactions can be re-enriched
  • AI enrichment records are deleted - The history of AI changes is cleared
  • User edits are preserved - If you manually changed a category after AI set it, your change is kept

Evaluation system

Test and compare different LLMs for your specific use case. The eval system helps you benchmark models for transaction categorization, merchant detection, and chat assistant functionality. See the evaluation framework documentation for details on:
  • Running evaluations
  • Comparing models
  • Creating custom datasets
  • Langfuse integration for tracking experiments
Sure’s AI assistant can search documents uploaded to a family’s vault. Documents are indexed in a vector store, and the assistant retrieves relevant passages when answering questions.

Supported backends

OpenAI (default)

No extra configuration is needed. If you have OPENAI_ACCESS_TOKEN set for the AI assistant, document search works automatically.

Pgvector (self-hosted)

Use PostgreSQL’s pgvector extension for fully local document search. All data stays on your infrastructure. Requirements:
  • Use the pgvector/pgvector:pg16-trixie Docker image instead of postgres:16
  • An embedding model served via an OpenAI-compatible /v1/embeddings endpoint (for example, Ollama with mxbai-embed-large)
  • Run migrations with VECTOR_STORE_PROVIDER=pgvector set to create the vector_store_chunks table
The LLM and embedding endpoints are independent. A common fully local setup uses an OpenAI-compatible chat model via OPENAI_URI_BASE, pgvector for storage, and a separate embedding model via EMBEDDING_URI_BASE. Sure enables the vector extension automatically when it first provisions the chunks table, provided the database user has permission. If the AI status page reports the extension is available but not enabled, connect as the PostgreSQL superuser and run:
If you use Ollama, pull the embedding model before starting Sure:
Do not change EMBEDDING_MODEL for an existing pgvector index without rebuilding it. Vectors from different models are not comparable even when they have the same dimensions. Remove existing documents from Sure, drop the chunks table, update the embedding settings, restart Sure, and re-upload the source documents.

Verifying the configuration

Super-admins can open System health → AI at /admin/system_health?tab=ai to run live checks. The tab verifies:
  • The configured LLM model is accessible
  • The vector store responds correctly
  • The embedding endpoint returns vectors with the expected dimensions
These checks run from the web process. To verify that worker processes can also reach the configured provider, click Verify worker configuration on the same tab. See AI status tab and Verifying worker configuration in the self-hosting guide for details on the checks, worker-specific caveats, and how to tune probe timeouts.

Additional environment variables

These optional variables fine-tune provider selection and the behavior of the OpenAI-compatible provider. See Anthropic environment variables for the Anthropic-specific options. See Token budget for LLM_CONTEXT_WINDOW, LLM_MAX_RESPONSE_TOKENS, and related variables.

Chat response timeout

Sure uses two separate timeouts for AI chat turns:
  • OPENAI_REQUEST_TIMEOUT — bounds each individual HTTP call to the model. The default is 60 seconds.
  • AI_RESPONSE_TIMEOUT — a whole-turn watchdog that starts when the message is queued and covers everything: queue wait, every model call, and all tool executions in between. The default is 90 seconds, which is sized for typical cloud latency.

Why the default 90 seconds is often too short for local models

Custom OpenAI-compatible providers (Ollama, LM Studio, etc.) route through a synchronous code path, so nothing renders until the full reply is generated. On top of that, a tool-using turn runs multiple model calls in sequence. The total time the watchdog must cover is:
With the defaults (ASSISTANT_MAX_TOOL_CALL_ITERATIONS=8, OPENAI_REQUEST_TIMEOUT=60), a worst-case turn takes up to 540 seconds of model time — far beyond the 90-second watchdog. The chat will report “assistant not available” even though the model is still generating a reply. The cheapest lever is lowering ASSISTANT_MAX_TOOL_CALL_ITERATIONS rather than setting a very large timeout. Fewer iterations means a shorter worst-case bound, and long tool chains fail with a clear limit error instead of a silent timeout. For a local Ollama setup with slow generation:
In compose.yml, pass ASSISTANT_MAX_TOOL_CALL_ITERATIONS alongside the other AI variables so the setting actually reaches the web and worker containers:
Leave the value empty to let the app’s own default govern, or set it explicitly to cap tool-call rounds. For cloud providers (OpenAI, Anthropic) the defaults are usually fine. If you see timeouts, raise AI_RESPONSE_TIMEOUT using the formula above.
AI_RESPONSE_TIMEOUT must be sized as a sum, not just set above OPENAI_REQUEST_TIMEOUT. The watchdog covers the entire turn — queue wait, every model call, and all tool executions — so the bound is:
Setting AI_RESPONSE_TIMEOUT equal to or below OPENAI_REQUEST_TIMEOUT means any tool-using turn will always time out. The 90-second default is sized for typical cloud latency; use the formula above once per-call latency approaches the timeout.

Configure via settings UI

AI_RESPONSE_TIMEOUT is also configurable from the web interface:
  1. Go to SettingsSelf-Hosting
  2. Scroll to the AI Provider section
  3. Set Chat Response Timeout to your desired value in seconds
The environment variable takes precedence over the UI setting. The minimum accepted value is 30 seconds.

Docker compose example

Basic Ollama setup

Advanced AI setup with OpenClaw

For advanced AI features including code execution and tool use, you can use the local-ai profile with OpenClaw:
To use the local AI setup:
The local-ai profile includes:
  • Ollama - Local LLM inference
  • OpenClaw - Gateway providing enhanced AI capabilities and tool use
  • Automatic routing between Sure and the AI stack