README file from
GithubObsidian AI Providers
AI Providers manages shared AI provider settings and gives other Obsidian plugins a common API for generation, tool calling, embeddings, and vector retrieval.
Think of it like a control panel where you can:
- Store your API keys and settings for AI services
- Share these settings with other Obsidian plugins
- Avoid entering the same AI settings multiple times
When another plugin calls the SDK, AI Providers sends generation, tool-calling, and embedding requests to the configured local or remote provider. It also caches embeddings and ranks document chunks locally for vector-based retrieval.
Required by plugins
Supported providers
- OpenAI
- OpenRouter
- OpenCode Go (Chat Completions models)
- Anthropic
- Google Gemini
- Mistral AI
- Together AI
- Fireworks AI
- Perplexity AI
- DeepSeek
- xAI (Grok)
- Cerebras
- Z.AI
- Groq
- 302.AI
- Novita AI
- DeepInfra
- SambaNova
- LM Studio
- Ollama (and Open WebUI)
- OpenAI compatible API
Features
- Fully encapsulated API for working with AI providers
- Develop AI plugins faster without dealing directly with provider-specific APIs
- Easily extend support for additional AI providers in your plugin
- Available in 11 languages: English, Spanish, French, Italian, Portuguese, German, Russian, Chinese, Japanese, Korean, and Dutch
Installation
Obsidian plugin store (recommended)
This plugin is available in the Obsidian community plugin store https://obsidian.md/plugins?id=ai-providers
BRAT
You can install this plugin via BRAT: pfrankov/obsidian-ai-providers
Create AI provider
Models and capabilities
Refreshing models selects the first returned model. An empty list or a failed refresh keeps the current model selection. Capability checkbox edits and accepted Check results save immediately for existing providers; new providers keep them locally until Save.
Changing the provider type, URL, or API key, or closing the form, discards pending refresh/check results. Changing the selected model or editing its capability checkboxes also discards a pending check. Requests already sent to the provider continue running and may still incur charges.
Optional reasoning modes
The model capabilities section includes manual reasoning-mode checkboxes for supported adapters. Select only modes documented for your model and endpoint. These are declarations, not automatic detection: Check probes text, embeddings, tools, and vision, and preserves the manual reasoning set. Checking a mode does not change other plugins' requests or set a shared default. A consuming plugin must explicitly select a declared mode for each request.
The checkboxes offer each adapter's wire vocabulary; they do not establish model support. Nothing is selected automatically. Model names are only keys for saved capabilities: changing or adding a model name never needs a code change.
| Provider transport | Request field | Manually selectable vocabulary |
|---|---|---|
| OpenAI Chat Completions | reasoning_effort |
none, minimal, low, medium, high, xhigh, max |
| Z.AI | reasoning_effort |
low, high, max |
| OpenRouter | reasoning.effort |
none, minimal, low, medium, high, xhigh, max |
| Ollama / Open WebUI | top-level think |
true, false, low, medium, high |
The saved per-model declarations are the source of truth for request selection. Select only values supported by your endpoint. The service rejects undeclared values and values outside the adapter vocabulary; remote support is not probed. It does not infer modes, sampling compatibility, tool support or API routing from model names. Native Anthropic reasoning is not implemented.
Omission preserves the API default; it does not mean thinking is disabled.
none, max and xhigh are passed literally. No intensity mapping, token budget,
sampling rewrite or reasoning-specific fallback/retry is added. Sampling and tools
remain as supplied by the consumer. An endpoint may reject their combination with
reasoning; that error is surfaced. Consumers must explicitly omit incompatible
sampling options themselves. This feature adds no sampling-default control.
Contracts: OpenAI reasoning, OpenAI model compatibility, Z.AI, OpenRouter and its per-model metadata, Ollama.
Ollama
- Install Ollama.
- Install Gemma 2
ollama pull gemma2or any preferred model from the library. - Select
OllamainProvider type - Click refresh button and select the model that suits your needs (e.g.
gemma2)
Additional: if you have issues with streaming completion with Ollama try to set environment variable OLLAMA_ORIGINS to *:
- For MacOS run
launchctl setenv OLLAMA_ORIGINS "*". - For Linux and Windows check the docs.
OpenAI
- Select
OpenAIinProvider type - Set
Provider URLtohttps://api.openai.com/v1 - Retrieve and paste your
API keyfrom the API keys page - Click refresh button and select the model that suits your needs (e.g.
gpt-4o)
OpenAI compatible server
There are several options to run local OpenAI-like server:
- Open WebUI
- llama.cpp
- llama-cpp-python
- LocalAI
- Obabooga Text generation web UI
- LM Studio
- ...maybe more
OpenRouter
- Select
OpenRouterinProvider type - Set
Provider URLtohttps://openrouter.ai/api/v1 - Retrieve and paste your
API keyfrom the API keys page - Click refresh button and select the model that suits your needs (e.g.
anthropic/claude-3.7-sonnet)
OpenCode Go
- Select
OpenCode GoinProvider type. The default URL ishttps://opencode.ai/zen/go/v1. - Enter your OpenCode Go API key.
- Enter a model ID whose documented endpoint
ends in
/chat/completions(for example,glm-5.2).
This adapter supports Chat Completions only. Responses and Messages models and
embeddings are not supported. Model entry is manual because Go's /models list
mixes protocols without identifying the API type. No model is selected automatically;
check the current endpoint table before entering an ID. Unsupported model errors
from the service are surfaced without switching protocols.
OpenCode Go is intended for coding-agent traffic.
Adding the provider does not make a consuming plugin a coding agent or establish
that other uses are permitted. Requests identify this plugin as
obsidian-ai-providers/<version> and include an opaque session UUID. SDK consumers
should reuse conversationId for related calls; without one, each call gets a
fresh UUID that remains stable during SDK retries and transport fallback. Go
always uses the existing Electron/Obsidian HTTP transport, ignoring the developer
Use native fetch setting, because Chromium fetch drops the required User-Agent.
Google Gemini
- Select
Google GeminiinProvider type - Set
Provider URLtohttps://generativelanguage.googleapis.com/v1beta/openai - Retrieve and paste your
API keyfrom the API keys page - Click refresh button and select the model that suits your needs (e.g.
gemini-1.5-flash)
LM Studio
- Select
LM StudioinProvider type - Set
Provider URLtohttp://localhost:1234/v1 - Click refresh button and select the model that suits your needs (e.g.
gemma2)
Groq
- Select
GroqinProvider type - Set
Provider URLtohttps://api.groq.com/openai/v1 - Retrieve and paste your
API keyfrom the API keys page - Click refresh button and select the model that suits your needs (e.g.
llama3-70b-8192)
For plugin developers
Docs: How to integrate AI Providers in your plugin.
Provider migration returns false if its confirmation dialog is canceled or
dismissed (including Escape or clicking outside), without adding or saving a
provider. Confirmed migrations resolve with the provider after settings are saved.
Requests using Obsidian's HTTP transport preserve provider error status, headers,
and body for the provider SDK's error handling and retries, including Retry-After.
Embedding cache
Cached embeddings are isolated by provider ID, type, full URL, and model. Renaming a provider or rotating its API key preserves cache hits. Changing the model behind an unchanged endpoint/model name, or account-specific routing, cannot be detected by this identity.
Older cache records do not identify their endpoint, so they are retained but ignored. The first subsequent use of each previously cached text recomputes its embedding and sends that text to the current provider again. This one-time lazy rebuild can take time and incur provider charges; no background rebuild or startup provider request is performed. Concurrent writes preserve each call's new entries, but simultaneous misses can still send the same text more than once.
Development checks
Use Node.js 24 and install the committed dependencies with npm ci.
Run npm run format:check, npm run check, npm run build,
npm run sdk:build, and npm run example:build before submitting a change.
The check command runs lint, tests with 100% coverage thresholds, and type checks.
These checks and builds also run on pull requests.
Quick reference (details in SDK docs):
try {
const finalText = await aiProviders.execute({
provider,
prompt: "Hello",
onProgress: (chunk, full) => {/* stream UI update */},
abortController
});
// use finalText
} catch (e) {
// handle error / abort
}
Tool-calling loops are available via toolsExecute() (SDK 1.7.0 / Service API v4). It is message-only and uses top-level tools / tool_choice, returning an OpenAI-style assistant message (role, content, tool_calls) that you can append directly to messages history.
Ollama tool calls are returned in arrival order across streamed chunks, including
repeated calls, with sequential IDs (call_1, call_2, ...).
Removed callbacks: onEnd / onError — promise resolve/reject covers them (only onProgress remains for streaming). Legacy chainable handler also deprecated.
Roadmap
- Docs for devs
- Ollama context optimizations
- German translations
- Chinese translations
- Update to latest OpenAI version and embedding models
- Russian translations
- Groq Provider support
- Passing messages instead of one prompt
- Anthropic Provider support
- Shared embeddings to avoid re-embedding the same documents multiple times
- Spanish, Italian, French, Dutch, Portuguese, Japanese, Korean translations
- Encapsulated vector-based retrieval for RAG
My other Obsidian plugins
- Local GPT that assists with local AI for maximum privacy and offline access.
- Colored Tags that colorizes tags in distinguishable colors.