How to Configure Multiple AI Providers in Open Notebook: Step-by-Step Setup
Open Notebook stores AI provider credentials in SurrealDB and allows you to assign different providers to individual notebooks or specific tasks, enabling workflows like using Ollama for local embeddings while routing chat requests to OpenAI's GPT-4.
Open Notebook (lfnovo/open-notebook) is an open-source knowledge management platform built with a provider-agnostic architecture. When you configure multiple AI providers in Open Notebook, you enable flexible AI workflows where each notebook can use different models for chat, embeddings, and transformations without server restarts.
Step 1: Register Provider Credentials in Settings
Unlike traditional setups that rely on environment variables, Open Notebook persists credentials in its SurrealDB backend. Navigate to Settings → API Keys in the UI (/frontend/src/pages/settings/api-keys.tsx) and click Add Credential.
For each provider, supply the required authentication details as documented in /docs/5-CONFIGURATION/ai-providers.md:
- OpenAI:
sk-...API key - Anthropic:
sk-ant-...API key - Ollama: Base URL such as
http://localhost:11434 - OpenAI-compatible servers: Custom base URL like
http://localhost:5000/v1
The data is stored in the credential table defined in /open_notebook/domain/credential.py, enabling runtime credential management without configuration file changes.
Step 2: Discover and Synchronize Available Models
After saving credentials, the system queries each provider's API to fetch available models. The backend handles this through the API router in /api/routers/models.py, specifically exposing two endpoints: /api/models/providers (for listing) and /api/models/sync/{provider} (for synchronization).
You can trigger a synchronization programmatically to verify your setup:
import requests
# Sync models for a specific provider identifier
provider_id = "ollama_local"
response = requests.post(f"http://localhost:8000/api/models/sync/{provider_id}")
print(response.json())
# Output: {"synced": ["llama2:latest", "nomic-embed-text:latest"], "provider": "ollama_local"}
The discovered models populate the Settings → Models interface, where you can enable specific models for use across the application.
Step 3: Assign Default Providers to Notebooks
Each notebook maintains its own default AI provider setting stored in /open_notebook/domain/notebook.py. When you create or edit a notebook:
- Open the notebook settings panel
- Select the Default AI Provider dropdown
- Choose from your configured providers (e.g., "OpenAI Production" or "Local Ollama")
This selection determines which model list appears when you initiate chats or run transformations scoped to that notebook.
Step 4: Mix Providers for Different Operations
Open Notebook supports provider-specific routing for distinct AI tasks within the same notebook. The embedding utility in /open_notebook/utils/embedding.py automatically selects the appropriate model based on the credential associated with a source document.
For example, configure your workflow as follows:
- Chat/Generation: Use GPT-4 via OpenAI for high-quality conversational responses
- Embeddings: Use
nomic-embed-textvia local Ollama for cost-effective vectorization
When processing sources, the ingestion pipeline checks the credential record stored in SurrealDB and routes embedding requests to the specified provider's endpoint.
Override Providers During Chat Sessions
For ad-hoc experimentation, you can override the default provider without changing notebook settings. The chat panel component (/frontend/src/components/source/ChatPanel.tsx) includes a Model Override control that lets you switch models on a per-session basis.
This is useful for A/B testing prompts against different providers or using a fast local model for initial drafts before switching to a cloud provider for refinement.
Summary
Configuring multiple AI providers in Open Notebook relies on database-backed credential management rather than static environment configuration:
- Store API keys in Settings → API Keys, which writes to the SurrealDB
credentialtable defined in/open_notebook/domain/credential.py - Sync available models via the
/api/models/sync/{provider}endpoint implemented in/api/routers/models.py - Assign default providers per notebook using the schema in
/open_notebook/domain/notebook.py - Mix providers for specific tasks using the provider-aware embedding utility in
/open_notebook/utils/embedding.py - Switch models dynamically using the override controls in
/frontend/src/components/source/ChatPanel.tsx
Frequently Asked Questions
Where are AI provider API keys stored in Open Notebook?
API keys are stored in SurrealDB within the credential table (/open_notebook/domain/credential.py), not as environment variables. This architecture allows you to add, update, or remove providers at runtime without restarting the server or redeploying containers.
Can I use different AI providers for chat and embeddings in the same notebook?
Yes. The source ingestion pipeline uses /open_notebook/utils/embedding.py to select embedding models based on the source's associated credential, while chat operations use the notebook's default provider or a session-specific override from /frontend/src/components/source/ChatPanel.tsx.
How do I add a local Ollama instance as a provider?
Navigate to Settings → API Keys, click Add Credential, and enter your Ollama base URL (e.g., http://localhost:11434) in the API key field. The system treats this as an OpenAI-compatible endpoint and discovers available models via the /api/models/sync/{provider} endpoint.
Do I need to restart Open Notebook after adding new credentials?
No. Because credentials are stored in SurrealDB and loaded dynamically by the models router in /api/routers/models.py, new providers appear immediately in the UI. Existing notebooks continue functioning with their previously selected providers while new options become available without service interruption.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →