> ## Documentation Index
> Fetch the complete documentation index at: https://docs.core-ai.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Providers

> Learn how providers work in core-ai and how to use OpenAI, Azure OpenAI, Anthropic, Google GenAI, and Mistral

## 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:

```typescript theme={null}
type Provider = {
    chatModel(modelId: string): ChatModel;
    embeddingModel?(modelId: string): EmbeddingModel;
    imageModel?(modelId: string): ImageModel;
};
```

<Note>
  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.
</Note>

## OpenAI

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

### Creating a Provider

```typescript theme={null}
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

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

### Getting Models

```typescript theme={null}
const gpt5 = openai.chatModel('gpt-5-mini');
const embeddings = openai.embeddingModel('text-embedding-3-small');
const imageModel = openai.imageModel('gpt-image-1');
```

<Note>
  `createOpenAI` uses the **Responses API** by default. For the Chat
  Completions API, use `createOpenAICompat` from `@core-ai/openai/compat`.
</Note>

## 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

```typescript theme={null}
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

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

### Getting Models

```typescript theme={null}
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

```typescript theme={null}
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

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

### Getting Models

```typescript theme={null}
const claude = anthropic.chatModel('claude-sonnet-4-6');
const claudeOpus = anthropic.chatModel('claude-opus-4-6');
```

<Note>
  Anthropic requires a `maxTokens` value for all requests. The
  `defaultMaxTokens` option sets a default value that can be overridden per
  request.
</Note>

## Google GenAI

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

### Creating a Provider

```typescript theme={null}
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

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

### Getting Models

```typescript theme={null}
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

```typescript theme={null}
import { createMistral } from '@core-ai/mistral';

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

### Provider Options

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

### Getting Models

```typescript theme={null}
// 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

```typescript theme={null}
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

```typescript theme={null}
type OmnifactProviderOptions = {
    apiKey?: string;
    baseURL?: string;
};
```

### Getting Models

```typescript theme={null}
// 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:

```typescript theme={null}
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

| Provider     | Chat | Embeddings | Images | Special Features                        |
| ------------ | ---- | ---------- | ------ | --------------------------------------- |
| OpenAI       | ✓    | ✓          | ✓      | Most comprehensive model selection      |
| Azure OpenAI | ✓    | ✗          | ✗      | Azure deployments and Entra ID auth     |
| Anthropic    | ✓    | ✗          | ✗      | Extended thinking, prompt caching       |
| Google GenAI | ✓    | ✓          | ✓      | Gemini models with multimodal support   |
| Mistral      | ✓    | ✓          | ✗      | Efficient open-source options           |
| Omnifact     | ✓    | ✗          | ✗      | Organization gateway for enabled models |

## Next Steps

* Learn about [Models](/concepts/models) to understand different model types
* Explore [Messages](/concepts/messages) to see how to structure conversations
* Configure models with [Configuration](/concepts/configuration) options
