Skip to main content

Overview

Providers are the bridge between core-ai and LLM services like OpenAI, Azure OpenAI, Anthropic, Google GenAI, and Mistral. Each provider implements a unified interface that abstracts away provider-specific details, allowing you to switch between providers with minimal code changes.

Provider Interface

All providers implement methods to create model instances:
type Provider = {
    chatModel(modelId: string): ChatModel;
    embeddingModel?(modelId: string): EmbeddingModel;
    imageModel?(modelId: string): ImageModel;
};
Not all providers support all model types. For example, Anthropic only supports chat models, while OpenAI and Google GenAI support chat, embedding, and image models.

OpenAI

OpenAI is one of the most popular providers, offering chat, embedding, and image generation models.

Creating a Provider

import { createOpenAI } from '@core-ai/openai';

const openai = createOpenAI({
    apiKey: process.env.OPENAI_API_KEY, // Optional: defaults to OPENAI_API_KEY env var
    baseURL: 'https://api.openai.com/v1', // Optional: custom base URL
});

Provider Options

type OpenAIProviderOptions = {
    apiKey?: string;
    baseURL?: string;
    client?: OpenAI; // Optional: bring your own OpenAI client
};

Getting Models

const gpt5 = openai.chatModel('gpt-5-mini');
const embeddings = openai.embeddingModel('text-embedding-3-small');
const imageModel = openai.imageModel('gpt-image-1');
createOpenAI uses the Responses API by default. For the Chat Completions API, use createOpenAICompat from @core-ai/openai/compat.

Azure OpenAI

Azure OpenAI provides chat models deployed in your Azure resource. The provider uses the v1 Chat Completions API by default and can opt into Azure’s classic API.

Creating a Provider

import { createAzureOpenAI } from '@core-ai/azure-openai';

const azure = createAzureOpenAI({
    apiKey: process.env.AZURE_OPENAI_API_KEY,
    endpoint: process.env.AZURE_OPENAI_ENDPOINT,
});

Provider Options

type AzureOpenAIProviderOptions = {
    api?: 'v1' | 'classic';
    apiKey?: string;
    endpoint?: string;
    apiVersion?: string;
    deployment?: string;
    azureADTokenProvider?: () => Promise<string>;
    client?: OpenAIChatClient;
};

Getting Models

const model = azure.chatModel('gpt-5-mini-deployment');
Use your Azure OpenAI deployment name as the model id.

Anthropic

Anthropic provides powerful chat models like Claude, with advanced capabilities for extended thinking and reasoning.

Creating a Provider

import { createAnthropic } from '@core-ai/anthropic';

const anthropic = createAnthropic({
    apiKey: process.env.ANTHROPIC_API_KEY,
    defaultMaxTokens: 4096, // Optional: default max tokens for responses
});

Provider Options

type AnthropicProviderOptions = {
    apiKey?: string;
    baseURL?: string;
    client?: Anthropic; // Optional: bring your own Anthropic client
    defaultMaxTokens?: number; // Optional: defaults to 4096
};

Getting Models

const claude = anthropic.chatModel('claude-sonnet-4-6');
const claudeOpus = anthropic.chatModel('claude-opus-4-6');
Anthropic requires a maxTokens value for all requests. The defaultMaxTokens option sets a default value that can be overridden per request.

Google GenAI

Google GenAI provides access to Gemini models for chat, embeddings, and image generation.

Creating a Provider

import { createGoogleGenAI } from '@core-ai/google-genai';

const google = createGoogleGenAI({
    apiKey: process.env.GOOGLE_API_KEY,
    apiVersion: 'v1beta', // Optional: API version
    baseUrl: 'https://generativelanguage.googleapis.com', // Optional
});

Provider Options

type GoogleGenAIProviderOptions = {
    apiKey?: string;
    apiVersion?: string;
    baseUrl?: string;
    client?: GoogleGenAI; // Optional: bring your own GoogleGenAI client
};

Getting Models

const gemini = google.chatModel('gemini-3.1-pro');
const embeddings = google.embeddingModel('text-embedding-004');
const imagen = google.imageModel('imagen-3.0');

Mistral

Mistral provides efficient open-source and proprietary models for chat and embeddings.

Creating a Provider

import { createMistral } from '@core-ai/mistral';

const mistral = createMistral({
    apiKey: process.env.MISTRAL_API_KEY,
    baseURL: 'https://api.mistral.ai', // Optional
});

Provider Options

type MistralProviderOptions = {
    apiKey?: string;
    baseURL?: string;
    client?: Mistral; // Optional: bring your own Mistral client
};

Getting Models

// Chat models
const mistralLarge = mistral.chatModel('mistral-large-2512');
const mistralMedium = mistral.chatModel('mistral-medium-2508');
const mistralSmall = mistral.chatModel('mistral-small');

// Embedding models
const embeddings = mistral.embeddingModel('mistral-embed');

Omnifact

Omnifact provides access to the Omnifact API Gateway — an OpenAI-compatible endpoint for chat completions backed by your organization’s enabled models.

Creating a Provider

import { createOmnifact } from '@core-ai/omnifact';

const omnifact = createOmnifact({
    apiKey: process.env.OMNIFACT_API_KEY,
    // baseURL defaults to https://connect.omnifact.ai/v1/gateway
});

Provider Options

type OmnifactProviderOptions = {
    apiKey?: string;
    baseURL?: string;
};

Getting Models

// EU-hosted models use the eu/ prefix.
const model = omnifact.chatModel('eu/gpt-5-mini');
Use model IDs enabled for your organization in Omnifact. Pass providerOptions.openai for supported Chat Completions options (same API surface as @core-ai/openai/compat).

Using Custom Clients

All providers support bringing your own client instance, which is useful for advanced configuration:
import OpenAI from 'openai';
import { createOpenAI } from '@core-ai/openai';

const customClient = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY,
    timeout: 30000,
    maxRetries: 3,
    // Any other OpenAI client options
});

const openai = createOpenAI({ client: customClient });

Provider Comparison

ProviderChatEmbeddingsImagesSpecial Features
OpenAIMost comprehensive model selection
Azure OpenAIAzure deployments and Entra ID auth
AnthropicExtended thinking, prompt caching
Google GenAIGemini models with multimodal support
MistralEfficient open-source options
OmnifactOrganization gateway for enabled models

Next Steps

  • Learn about Models to understand different model types
  • Explore Messages to see how to structure conversations
  • Configure models with Configuration options