Skip to main content
What it provides:
  • 🔐 Centralized Credentials Management: Admin manages credentials, end users use without hassle.
  • 🌐 Support for Multiple AI Providers: OpenAI, Anthropic, and many open-source models.
  • 💬 Support for Various AI Capabilities: Chat, Image, Agents, and more.

Using the AI SDK

NRAI integrates with the AI SDK to provide a unified interface for calling LLMs across multiple AI providers. Here’s an example on how to use the AI SDK’s generateText function to call an LLM in your actions.

AI Properties Helper

Use aiProps to create consistent AI-related properties:

Advanced Options

The aiProps helper includes an advancedOptions property that provides provider-specific configuration options. These options are dynamically generated based on the selected provider and model. To add advanced options for your new provider, update the advancedOptions property in packages/addons/community/common/src/lib/ai/index.ts:
The advanced options automatically update when users change their provider or model selection, ensuring only relevant options are shown.

Adding a New AI Provider

To add support for a new AI provider, you need to update several files in the NRAI codebase. Here’s a complete guide: Before starting, check the Vercel AI SDK Providers documentation to see all available providers and their capabilities.

1. Install Required Dependencies

First, add the AI SDK for your provider to the project dependencies:

2. Update SUPPORTED_AI_PROVIDERS Array

First, add your new provider to the SUPPORTED_AI_PROVIDERS array in packages/ai-providers-shared/src/lib/supported-ai-providers.ts:

3. Update createAIModel Function

Add a case for your provider in the createAIModel function in packages/shared/src/lib/ai/ai-sdk.ts:

4. Handle Provider-Specific Requirements

OpenAI supports both language and image models, but some providers may have specific requirements or limitations:

5. Test Your Integration

After adding the provider, test it by:
  1. Configure credentials in the Admin panel for your new provider
  2. Create a test action using aiProps to select your provider and models
  3. Verify functionality by running a flow with your new provider
Once these changes are made, your new AI provider will be available in the aiProps dropdowns and can be used with generateText and other AI SDK functions throughout NRAI.