Agentoria

Providers

One LlmClient port; Anthropic, OpenAI, and any OpenAI-compatible endpoint.

A provider is an LlmClient — the only thing the agent loop needs to talk to a model. Agentoria ships two adapters plus a mock, and anything else that satisfies the interface works.

Anthropic

import { createAnthropicProvider } from '@agentoria/runtime';

const provider = createAnthropicProvider({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  model: 'claude-sonnet-4-6',
  cacheSystem: true, // opt-in prompt caching for the stable system prompt
});

OpenAI-compatible

The OpenAI adapter covers OpenAI and any OpenAI-compatible endpoint — Groq, Together, DeepSeek, Ollama, and Gemini's OpenAI-compat API — via baseURL:

import { createOpenAiProvider } from '@agentoria/runtime';

const openai = createOpenAiProvider({ apiKey: process.env.OPENAI_API_KEY!, model: 'gpt-4o' });

const deepseek = createOpenAiProvider({
  apiKey: process.env.DEEPSEEK_API_KEY!,
  baseURL: 'https://api.deepseek.com/v1',
  model: 'deepseek-chat',
});

const ollama = createOpenAiProvider({ apiKey: 'ollama', baseURL: 'http://localhost:11434/v1', model: 'llama3.1' });

Both adapters retry transient failures (429 / 5xx / network) with exponential backoff and Retry-After support; tune with maxRetries and retryBaseMs.

Testing with a mock

MockLlmClient replays a scripted stream — deterministic tests with no network:

import { MockLlmClient } from '@agentoria/runtime';

const provider = new MockLlmClient([
  { type: 'text', delta: 'Hello ' },
  { type: 'text', delta: 'world' },
]);

Fallback

withFallback returns an LlmClient that tries each provider in order until one starts streaming — useful for provider outages. See Resilience.

import { withFallback } from '@agentoria/runtime';

const provider = withFallback(anthropic, openai); // primary, then backup

On this page