LLM providers.
Sentinel works with Gemini, OpenAI, Claude, and Ollama out of the box. Swap the underlying model with a single provider option — no other code changes needed.
Overview
| Provider | Class | Default model | Peer dependency | Notes |
|---|---|---|---|---|
| Gemini | GeminiProvider | gemini-3-flash-preview | none (bundled) | Default provider. Set GEMINI_VERSION env to override model. |
| OpenAI | OpenAIProvider | gpt-4o | npm install openai | Supports any OpenAI-compatible API via baseURL. |
| Claude | ClaudeProvider | claude-sonnet-5 | npm install @anthropic-ai/sdk | Model identifiers are forwarded to the Anthropic SDK. |
| Ollama | OllamaProvider | required | none (local) | Runs locally — no API key. Vision requires llava or bakllava. |
All providers implement automatic retry with exponential backoff on rate limit errors (HTTP 429/503), connection resets, and timeouts.
Gemini Built-in · No extra package
The default provider. No peer dependency — Gemini support is bundled with Sentinel. Get an API key at aistudio.google.com. Quotas depend on the model and your account.
import { Sentinel } from '@isoldex/sentinel';
// Shorthand — uses Gemini implicitly
const sentinel = new Sentinel({ apiKey: process.env.GEMINI_API_KEY! });Explicit constructor (to pin a specific model):
import { Sentinel, GeminiProvider } from '@isoldex/sentinel';
const sentinel = new Sentinel({
provider: new GeminiProvider({
apiKey: process.env.GEMINI_API_KEY!,
model: 'gemini-3-flash-preview', // or set GEMINI_VERSION in .env
}),
});GEMINI_API_KEY=your_key_here
GEMINI_VERSION=gemini-3-flash-preview # optional, this is the defaultOpenAI npm install openai
Supports GPT-4o and any other OpenAI model. Also works with any OpenAI-compatible API by setting baseURL — Groq, Together AI, Fireworks, and more.
import { Sentinel, OpenAIProvider } from '@isoldex/sentinel';
const sentinel = new Sentinel({
provider: new OpenAIProvider({
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o', // any OpenAI-compatible model
}),
});OpenAI-compatible APIs (Groq example):
// Works with any OpenAI-compatible API (Groq, Together, Fireworks, etc.)
import { Sentinel, OpenAIProvider } from '@isoldex/sentinel';
const sentinel = new Sentinel({
provider: new OpenAIProvider({
apiKey: process.env.GROQ_API_KEY!,
model: 'llama-3.3-70b-versatile',
baseURL: 'https://api.groq.com/openai/v1',
}),
});Claude npm install @anthropic-ai/sdk
Supports Anthropic models including Opus, Sonnet, and Haiku. The package default is claude-sonnet-5; pass model to select another model available to your account. Get an API key at console.anthropic.com.
import { Sentinel, ClaudeProvider } from '@isoldex/sentinel';
const sentinel = new Sentinel({
provider: new ClaudeProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
model: 'claude-sonnet-5',
}),
});Example model IDs — check availability with your provider
claude-opus-5 · claude-sonnet-5 · claude-haiku-4-5-20251001
Ollama Local · No API key
Run models locally with Ollama. No API key required. Supports vision via llava or bakllava models.
import { Sentinel, OllamaProvider } from '@isoldex/sentinel';
// Requires a running Ollama instance — https://ollama.com
const sentinel = new Sentinel({
provider: new OllamaProvider({
model: 'llama3.2',
baseURL: 'http://localhost:11434', // default
}),
});
// Pull a vision-capable model for visionFallback:
// $ ollama pull llavaCustom provider
Implement the LLMProvider interface to integrate any LLM — Mistral, Cohere, a fine-tuned model, or an internal API. No dummy Gemini apiKey is needed when provider is supplied. Only generateStructuredData and generateText are required.analyzeImage is optional — enables visionFallback.
import { Sentinel, z, type LLMProvider } from '@isoldex/sentinel';
type SchemaInput<T> = z.ZodType<T> | Record<string, unknown>;
// myApi is your own backend client; implement it for your service.
class MyProvider implements LLMProvider {
readonly modelName = 'my-model';
async generateStructuredData<T>(
prompt: string,
schema: SchemaInput<T>,
): Promise<T> {
// Call your API, parse the response, and return typed data
const response = await myApi.complete(prompt, schema);
return JSON.parse(response.text) as T;
}
async generateText(
prompt: string,
systemInstruction?: string,
): Promise<string> {
const response = await myApi.complete(prompt, { system: systemInstruction });
return response.text;
}
// Optional — enables vision grounding
async analyzeImage(
prompt: string,
imageBase64: string,
mimeType?: string,
): Promise<string> {
const response = await myApi.vision(prompt, imageBase64, mimeType);
return response.text;
}
}
const sentinel = new Sentinel({ provider: new MyProvider() });Retry behavior
All four built-in providers retry transient failures with jittered exponential backoff and Retry-After handling. No configuration required.
// Built-in providers make up to 3 attempts for transient failures.
// Exponential backoff uses jitter to spread concurrent retries.
// Retry-After (seconds or HTTP date) overrides the backoff ceiling,
// capped at 30 seconds; the actual wait includes jitter.
// Retryable: HTTP 429 / 5xx and transient connection/timeout errors.
// Structured output defaults to 16,000 tokens. Detected truncation
// triggers one retry at 32,000 tokens.