Skip to content

Add multi-provider AI support with Google and OpenAI-compatible providers. Extract shared AI types into new @directus/ai package.#26481

Merged
AlexGaillard merged 15 commits intomainfrom
bry/ai-provider-abstraction
Jan 20, 2026
Merged

Add multi-provider AI support with Google and OpenAI-compatible providers. Extract shared AI types into new @directus/ai package.#26481
AlexGaillard merged 15 commits intomainfrom
bry/ai-provider-abstraction

Conversation

@bryantgillespie
Copy link
Member

@bryantgillespie bryantgillespie commented Jan 13, 2026

Yikes... this one is a doozy that kept growing and growing and growing.

TODOS

  • Merge Docs PR
  • Check the Changeset (not sure I got versions right)

The big things...

  • Refactor AI providers from if statements into a nice new home in registry.ts using AI SDK createAIProviderRegistry to make it cleaner to add more / easier to maintain
  • Create a separate @directus/ai package to share models and types in /api and /app
  • Add support for OpenAI Compatible providers --- use Ollama or whatever you want (with all the extra little niceties like providerOptions from AI SDK so that folks can plug in reasoning or whatever provider/model specific stuff they want)
  • Adds Google AI Model support
  • Add "Allowed Models" for the big 3 providers + add custom option (in case OpenAI drops GPT-6 in the middle of a release cycle)
ScreenShot 2026-01-13 at 18 32 39@2x ScreenShot 2026-01-13 at 18 32 32@2x ScreenShot 2026-01-13 at 18 32 08@2x

⚠️ Not So Scary AI Alert

  • A lot of the boilerplate stuff (settings, scaffolding, translations) written by Claude Code.
  • All tests here were written by Claude Code with a few manual fixes.

This pull request introduces multi-provider AI support, enabling integration with Google and OpenAI-compatible providers in addition to existing providers. It refactors and centralizes AI configuration and validation logic, extracts shared types into a new @directus/ai package, and updates tests and code to support the new provider model and validation mechanisms.

AI Provider Support and Configuration

  • Added support for Google and OpenAI-compatible AI providers, alongside OpenAI and Anthropic, by updating dependencies and configuration handling in api/package.json and related files. [1] [2] [3]
  • Extracted shared AI types into a new @directus/ai package for better modularity and reuse.

Refactoring and Validation Logic

  • Refactored AI settings handling: replaced scattered API key usage with a unified AISettings object, and updated all references and test mocks accordingly. [1] [2] [3] [4] [5]
  • Implemented provider-specific model validation: models must be explicitly allowed for each provider (OpenAI, Anthropic, Google), with tests ensuring correct validation and error handling. OpenAI-compatible providers skip this restriction. [1] [2] [3]

Core AI Stream Logic Updates

  • Refactored createUiStream to be asynchronous, accept the new AISettings, and dynamically build provider configurations and registries, supporting multiple providers and future extensibility. [1] [2] [3] [4]
  • Enhanced error handling for missing or misconfigured providers, and improved system prompt logic. [1] [2]

Testing Improvements

  • Updated and expanded tests to cover new providers, model validation, and error cases, ensuring robust multi-provider support and correct configuration propagation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

These changes lay the groundwork for more flexible and secure AI integrations, making it easier to add or configure providers and enforce access controls on available models.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces multi-provider AI support for Directus, adding Google and OpenAI-compatible providers alongside the existing OpenAI and Anthropic support. It creates a new @directus/ai package to centralize AI-related types and model definitions, implements a provider abstraction layer via registry pattern, and updates AI SDK dependencies from beta to stable versions.

Changes:

  • Created @directus/ai package with shared types, model definitions, and helper functions
  • Added Google Gemini and OpenAI-compatible provider support in both API and app
  • Implemented provider registry abstraction with configuration building and model validation
  • Updated AI SDK packages to stable versions (3.0.x for providers, 6.0.25 for ai core)

Reviewed changes

Copilot reviewed 42 out of 43 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Updated AI SDK package versions to stable releases
pnpm-lock.yaml Updated lock file with new AI SDK versions and dependencies
packages/ai/* New package with shared AI types, model definitions, and tests
packages/types/src/settings.ts Added new AI provider settings types
packages/system-data/src/fields/settings.yaml Added UI fields for Google and OpenAI-compatible providers
api/src/database/migrations/20260110A-add-ai-provider-settings.ts Migration for new AI provider settings columns
api/src/ai/providers/* New provider abstraction layer with registry, options, and types
api/src/ai/chat/* Updated chat controllers and middleware for multi-provider support
app/src/ai/stores/use-ai.ts Updated model filtering logic for allowed models per provider
app/src/ai/models.ts Refactored to use shared package and added icon mapping
app/src/ai/components/logos/* Added Google and custom provider logo components
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 43 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@bryantgillespie bryantgillespie marked this pull request as ready for review January 13, 2026 23:44
@robluton
Copy link
Contributor

These ai features are really coming together!

When using Ollama locally, I tried both llama3.2 and llama3.1. I was able to chat using those models, but they couldn't access the tools. That being said, when I used the ollama cloud api endpoint and one of their cloud models, I had no issues, so maybe there is something with my local setup that is preventing access to the tools.

I love that we now have the option to add an openai-compatible provider. I think a future improvement could be to allow multiple openai-compatible providers. For example, when I was going between Ollama cloud and my Ollama local setup, I had to edit the single local provider, but I could see a case for someone wanting to use Ollama cloud for some models, and Ollama local for others, so having them both in there would be nice.

I think mostly everyone will be using the big providers though, and that experience is really great ❤️

Copy link
Contributor

@robluton robluton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎸

@bryantgillespie bryantgillespie changed the title AI Provider Abstraction + Google + OpenAI Compat Add multi-provider AI support with Google and OpenAI-compatible providers. Extract shared AI types into new @directus/ai package. Jan 20, 2026
@bryantgillespie bryantgillespie changed the title Add multi-provider AI support with Google and OpenAI-compatible providers. Extract shared AI types into new @directus/ai package. Add multi-provider AI support with Google and OpenAI-compatible providers. Extract shared AI types into new @directus/ai package. Jan 20, 2026
Copy link
Member

@AlexGaillard AlexGaillard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒🫘

@AlexGaillard AlexGaillard merged commit 8884e25 into main Jan 20, 2026
69 checks passed
@AlexGaillard AlexGaillard deleted the bry/ai-provider-abstraction branch January 20, 2026 22:28
@github-actions github-actions bot added this to the Next Release milestone Jan 20, 2026
@bryantgillespie
Copy link
Member Author

Just adding docs PR here for reference
directus/docs#540

@JoshTheDerf
Copy link
Contributor

Nicely done! Looking forward to this.

alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Feb 5, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [directus/directus](https://github.com/directus/directus) | minor | `11.14.1` → `11.15.0` |

---

### Release Notes

<details>
<summary>directus/directus (directus/directus)</summary>

### [`v11.15.0`](https://github.com/directus/directus/releases/tag/v11.15.0)

[Compare Source](directus/directus@v11.14.1...v11.15.0)

##### ⚠️ Potential Breaking Changes

**Attached prompts, content items, and visual editor elements to AI Assistant Context ([#&#8203;26512](directus/directus#26512) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))**
To use this feature, update [@&#8203;directus/visual-editing](https://github.com/directus/visual-editing) to v1.2.0+ on your website.

##### ✨ New Features & Improvements

- **[@&#8203;directus/app](https://github.com/directus/app)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
  - Attached prompts, content items, and visual editor elements to AI Assistant Context ([#&#8203;26512](directus/directus#26512) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Added multi-provider AI support with Google and OpenAI-compatible providers. Extracted shared AI types into new `@directus/ai` package. ([#&#8203;26481](directus/directus#26481) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Added toggle to allow comparing revision to previous revision ([#&#8203;26480](directus/directus#26480) by [@&#8203;robluton](https://github.com/robluton))
  - Added relational field support on x-axis of bar chart ([#&#8203;26489](directus/directus#26489) by [@&#8203;JamesW1](https://github.com/JamesW1))
  - Added visual editing support to the live preview split pane, including display options menu, full-width mode with drag-to-expand, and quick access to the Visual Editor module. ([#&#8203;26463](directus/directus#26463) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Changed permission-blocked fields from disabled to non-editable appearance ([#&#8203;26572](directus/directus#26572) by [@&#8203;HZooly](https://github.com/HZooly))
- **[@&#8203;directus/api](https://github.com/directus/api)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
  - Attached prompts, content items, and visual editor elements to AI Assistant Context ([#&#8203;26512](directus/directus#26512) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Added multi-provider AI support with Google and OpenAI-compatible providers. Extracted shared AI types into new `@directus/ai` package. ([#&#8203;26481](directus/directus#26481) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
- **[@&#8203;directus/sdk](https://github.com/directus/sdk)**
  - Fixed race condition and allow accessing the connected state ([#&#8203;26511](directus/directus#26511) by [@&#8203;Nitwel](https://github.com/Nitwel))
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
- **[@&#8203;directus/system-data](https://github.com/directus/system-data)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
- **[@&#8203;directus/types](https://github.com/directus/types)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
  - Added multi-provider AI support with Google and OpenAI-compatible providers. Extracted shared AI types into new `@directus/ai` package. ([#&#8203;26481](directus/directus#26481) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
- **[@&#8203;directus/errors](https://github.com/directus/errors)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
- **[@&#8203;directus/env](https://github.com/directus/env)**
  - Added deployment module for triggering deployments from Directus with Vercel as first supported provider ([#&#8203;26473](directus/directus#26473) by [@&#8203;gaetansenn](https://github.com/gaetansenn))
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
- **[@&#8203;directus/utils](https://github.com/directus/utils)**
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
- **[@&#8203;directus/ai](https://github.com/directus/ai)**
  - Attached prompts, content items, and visual editor elements to AI Assistant Context ([#&#8203;26512](directus/directus#26512) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Added multi-provider AI support with Google and OpenAI-compatible providers. Extracted shared AI types into new `@directus/ai` package. ([#&#8203;26481](directus/directus#26481) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
- **[@&#8203;directus/memory](https://github.com/directus/memory)**
  - Added distributed locking ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))

##### 🐛 Bug Fixes & Optimizations

- **[@&#8203;directus/app](https://github.com/directus/app)**
  - Replaced deprecated `ldapjs` with `ldapts` ([#&#8203;26363](directus/directus#26363) by [@&#8203;dstockton](https://github.com/dstockton))
  - Fixed an issue where the caret would jump to the end of the input in `v-template-input` when typing or updating content. ([#&#8203;26520](directus/directus#26520) by [@&#8203;mustafaazad03](https://github.com/mustafaazad03))
  - Fixed back button navigation on related items ([#&#8203;26553](directus/directus#26553) by [@&#8203;robluton](https://github.com/robluton))
  - Fixed table options menu clipping in markdown editor ([#&#8203;26487](directus/directus#26487) by [@&#8203;DamnItAzriel](https://github.com/DamnItAzriel))
  - Hide AI settings page when MCP and AI features are disabled through ENV ([#&#8203;26504](directus/directus#26504) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Updated dependency ([#&#8203;26518](directus/directus#26518) by [@&#8203;rijkvanzanten](https://github.com/rijkvanzanten))
  - Fixed inconsistent disabled state across interfaces ([#&#8203;26470](directus/directus#26470) by [@&#8203;formfcw](https://github.com/formfcw))
  - Fixed an issue where custom CSS classes applied to PrivateView were not rendered ([#&#8203;26523](directus/directus#26523) by [@&#8203;u12206050](https://github.com/u12206050))
  - Fixed WYSIWYG interface not rendering when field is named "tooltip" ([#&#8203;26581](directus/directus#26581) by [@&#8203;robluton](https://github.com/robluton))
  - Fixed issue preventing sidebar details from being fetched when navigating back ([#&#8203;26542](directus/directus#26542) by [@&#8203;robluton](https://github.com/robluton))
  - Fixed Vue warning by passing required prop to interfaces ([#&#8203;26506](directus/directus#26506) by [@&#8203;formfcw](https://github.com/formfcw))
  - Fixed hardcoded "Loading..." text in field tree by using translation key ([#&#8203;26526](directus/directus#26526) by [@&#8203;sinan-yildiz-marsus](https://github.com/sinan-yildiz-marsus))
  - Renamed AI Chat to AI Assistant ([#&#8203;26517](directus/directus#26517) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
- **[@&#8203;directus/api](https://github.com/directus/api)**
  - Improved error message for system field updates that are not schema.is\_indexed ([#&#8203;26548](directus/directus#26548) by [@&#8203;JamesW1](https://github.com/JamesW1))
  - Replaced deprecated `ldapjs` with `ldapts` ([#&#8203;26363](directus/directus#26363) by [@&#8203;dstockton](https://github.com/dstockton))
  - Changed users.last\_access display mode to absolute ([#&#8203;26548](directus/directus#26548) by [@&#8203;JamesW1](https://github.com/JamesW1))
- **[@&#8203;directus/system-data](https://github.com/directus/system-data)**
  - Added collaborative editing ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))
  - Added multi-provider AI support with Google and OpenAI-compatible providers. Extracted shared AI types into new `@directus/ai` package. ([#&#8203;26481](directus/directus#26481) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
  - Changed users.last\_access display mode to absolute ([#&#8203;26548](directus/directus#26548) by [@&#8203;JamesW1](https://github.com/JamesW1))
  - Renamed AI Chat to AI Assistant ([#&#8203;26517](directus/directus#26517) by [@&#8203;bryantgillespie](https://github.com/bryantgillespie))
- **[@&#8203;directus/env](https://github.com/directus/env)**
  - Fixed LDAP DN properties casted as arrays ([#&#8203;26579](directus/directus#26579) by [@&#8203;ComfortablyCoding](https://github.com/ComfortablyCoding))
- **[@&#8203;directus/memory](https://github.com/directus/memory)**
  - Handled empty buffers to prevent errors during race conditions or disconnects ([#&#8203;26172](directus/directus#26172) by [@&#8203;Nitwel](https://github.com/Nitwel))

##### 📦 Published Versions

- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/storage-driver-s3@&#8203;12.1.1`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`
- `@directus/[email protected]`

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4zLjYiLCJ1cGRhdGVkSW5WZXIiOiI0My4zLjYiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImltYWdlIl19-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/3752
Co-authored-by: Renovate Bot <[email protected]>
Co-committed-by: Renovate Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants