Multi-provider LLM module for the Pons platform.
The LLM module provides a unified interface to multiple AI providers, accessible via RPC from any other Pons module. Features include:
- Provider abstraction — Anthropic, OpenAI, DeepSeek, Ollama, Claude Code, GitHub Copilot
- Model routing — configurable default/fallback chains, per-request provider and model selection
- Auth profile rotation — multiple API keys per provider with automatic rotation
- Cost tracking — per-request cost calculation with daily/monthly limits
- Failover — automatic retry with fallback providers on failure
- Streaming — real-time token streaming via pub/sub bus
- Deno v2.0+
deno installConfigure providers in your workspace config:
models:
providers:
anthropic:
provider: anthropic
models: [claude-sonnet-4-20250514]
openai:
provider: openai
models: [gpt-4o]
authProfiles:
anthropic:
- id: key1
credential: sk-ant-...
routing:
default:
provider: anthropic
model: claude-sonnet-4-20250514deno run -A runner.tsdeno run -A cli.ts chat --provider anthropic --model claude-sonnet-4-20250514- model-router —
generateText,streamText,listModels,getCapabilities - providerRegistry —
listProviders,getProvider - authProfileManager —
listProfiles - cost-tracker —
getUsage,resetUsage
| Topic | Description |
|---|---|
llm:generate |
Async text generation (responds via replyTopic) |
llm:stream:request |
Streaming generation request |
| Topic | Description |
|---|---|
llm:stream:chunk |
Streaming response chunks |
usage:updated |
Cost/usage update events |
| Provider | Streaming | Tool Use | Notes |
|---|---|---|---|
| Anthropic | Yes | Yes | Claude models |
| OpenAI | Yes | Yes | GPT-4o, o1, etc. |
| DeepSeek | Yes | Yes | Via OpenAI-compatible API |
| Ollama | Yes | No | Local models |
| Claude Code | Yes | Yes | Via Claude Code CLI subprocess |
| GitHub Copilot | Yes | Yes | Via Copilot API with device auth |
See CONTRIBUTING.md for development setup and guidelines.