# How to Configure Multiple AI Providers for a Single Notebook in Open Notebook

> Configure multiple AI providers like OpenAI, Gemini, and Anthropic in Open Notebook. Store credentials in SurrealDB and assign models per notebook or session for flexible AI integration.

- Repository: [Luis Novo/open-notebook](https://github.com/lfnovo/open-notebook)
- Tags: how-to-guide
- Published: 2026-06-05

---

**Open Notebook lets you configure multiple AI providers—such as OpenAI, Anthropic, Google Gemini, and Ollama—for a single notebook by storing credentials in SurrealDB and assigning provider-specific models at the notebook or session level.**

The `lfnovo/open-notebook` repository is an open-source notebook application built for flexible, multi-provider AI workflows. You can configure multiple AI providers for a single notebook without editing environment variables or restarting the server, mixing local and remote models across chat, embeddings, and transformations.

## Add Provider Credentials via the Settings UI

Open Notebook stores all API credentials in a **SurrealDB**-backed `credential` table as modeled in [`/open_notebook/domain/credential.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/domain/credential.py). To add a new provider:

1. Navigate to **Settings → API Keys** in the UI, implemented in [`/frontend/src/pages/settings/api-keys.tsx`](https://github.com/lfnovo/open-notebook/blob/main//frontend/src/pages/settings/api-keys.tsx).
2. Click **Add Credential** for each service you want to enable.
3. Enter the provider-specific connection details. For example, point **Ollama** to `http://localhost:11434` or an OpenAI-compatible server to `http://localhost:5000/v1`.

The full list of supported providers and connection formats is documented in [`/docs/5-CONFIGURATION/ai-providers.md`](https://github.com/lfnovo/open-notebook/blob/main//docs/5-CONFIGURATION/ai-providers.md).

A typical credential record in SurrealDB contains the provider name and connection details:

```json
{
  "provider": "ollama",
  "base_url": "http://localhost:11434",
  "api_key": "not-required-for-local"
}

```

## Discover and Sync Models from Each Provider

After credentials are saved, the **Models** page at **Settings → Models** lists every model discovered from each configured provider. The discovery logic lives in [`/api/routers/models.py`](https://github.com/lfnovo/open-notebook/blob/main//api/routers/models.py), which exposes two key endpoints:

- `/api/models/providers` — lists all configured providers
- `/api/models/sync/{provider}` — triggers model discovery for a specific provider

You can refresh the available models for a provider by calling the sync endpoint:

```bash
curl -X POST http://localhost:8000/api/models/sync/openai

```

To verify the list of configured providers, use:

```bash
curl http://localhost:8000/api/models/providers

```

## Assign a Default AI Provider to a Notebook

Every notebook in Open Notebook can have its own default AI provider. The notebook schema defined in [`/open_notebook/domain/notebook.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/domain/notebook.py) stores this selection at the notebook level. When you create or edit a notebook, choose a provider from the **Default AI Provider** dropdown.

This setting determines which model list is presented when you start a chat or run a transformation inside that notebook. Each notebook can therefore use a different primary provider without affecting others in your workspace.

## Override Models Per Chat Session

You are not locked into the notebook default for every interaction. The chat panel component in [`/frontend/src/components/source/ChatPanel.tsx`](https://github.com/lfnovo/open-notebook/blob/main//frontend/src/components/source/ChatPanel.tsx) includes a **Model Override** control that lets you switch to any other enabled model on the fly.

This per-session override makes it easy to test responses across providers without changing notebook settings.

## Mix Providers for Different Notebook Tasks

Open Notebook supports provider-aware source ingestion, which means you can attach multiple sources to one notebook and process them with different providers. The `embed` service in [`/open_notebook/utils/embedding.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/utils/embedding.py) automatically selects the embedding model based on the credential associated with each source.

For example, you can use a fast local Ollama model to generate embeddings for uploaded documents while using OpenAI’s GPT-4 for chat queries in the same notebook. The pipeline routes embedding jobs to the correct provider without manual configuration each time.

## Update Providers Dynamically

Because all credentials live in the SurrealDB `credential` table, you can add, remove, or update providers at any time without restarting the application server. The UI reflects the new options immediately, and existing notebooks continue to work with any previously selected provider.

## Summary

- Store provider credentials in SurrealDB via **Settings → API Keys**, backed by [`/frontend/src/pages/settings/api-keys.tsx`](https://github.com/lfnovo/open-notebook/blob/main//frontend/src/pages/settings/api-keys.tsx) and [`/open_notebook/domain/credential.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/domain/credential.py).
- Sync available models through [`/api/routers/models.py`](https://github.com/lfnovo/open-notebook/blob/main//api/routers/models.py) using the `/api/models/sync/{provider}` endpoint.
- Assign a **Default AI Provider** per notebook in [`/open_notebook/domain/notebook.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/domain/notebook.py).
- Override the active model for individual chat sessions in [`/frontend/src/components/source/ChatPanel.tsx`](https://github.com/lfnovo/open-notebook/blob/main//frontend/src/components/source/ChatPanel.tsx).
- Run embedding tasks through the `embed` service in [`/open_notebook/utils/embedding.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/utils/embedding.py) using the provider linked to each source.
- Add or remove providers dynamically without server restarts.

## Frequently Asked Questions

### Can I use Ollama and OpenAI in the same notebook?

Yes. You can configure both providers in **Settings → API Keys** and assign either as the notebook default. You can also use Ollama for local embeddings via the `embed` service in [`/open_notebook/utils/embedding.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/utils/embedding.py) while keeping OpenAI as the chat provider.

### Where does Open Notebook store API keys?

API keys are stored in the SurrealDB-backed `credential` table as implemented in [`/open_notebook/domain/credential.py`](https://github.com/lfnovo/open-notebook/blob/main//open_notebook/domain/credential.py). They are not stored in environment variables or flat configuration files.

### Do I need to restart the server after adding a new AI provider?

No. Credentials are read from the database at runtime. Once you add a new provider through the UI, the `/api/models/providers` endpoint and model list update immediately without requiring a server restart.

### How do I change the model for just one chat session?

Use the **Model Override** control in the chat panel. This UI element is defined in [`/frontend/src/components/source/ChatPanel.tsx`](https://github.com/lfnovo/open-notebook/blob/main//frontend/src/components/source/ChatPanel.tsx) and lets you select a different enabled model for that specific session while leaving the notebook default unchanged.