@lanlinling/llm-providers
v0.0.1
Published
Multi-provider LLM adapter registry (OpenAI, Anthropic, Google, Azure, Amazon Bedrock, DeepSeek, Qwen, Kimi, MiniMax, GLM, SiliconFlow, Doubao, Grok, Ollama, and more) — extracted from OpenMAIC.
Readme
@lanlinling/llm-providers
Multi-provider LLM chat-completion adapter registry — OpenAI, Anthropic, Google, Azure, Amazon Bedrock, and every OpenAI-compatible provider (DeepSeek, Qwen, Kimi, MiniMax, GLM, SiliconFlow, Doubao, Grok, Ollama, and more). Extracted from OpenMAIC.
Also includes onehub — a personal self-hosted aggregator gateway (one key,
~180 models across vendors including Claude/GPT/Gemini/DeepSeek). See
TROUBLESHOOTING.md for why its model IDs and
capabilities (no extended thinking) differ from the native provider entries.
Install
{
"dependencies": {
"@lanlinling/llm-providers": "github:bluemomo112/ai-providers#path:packages/llm-providers"
}
}Add it to your project's pnpm-workspace.yaml (pnpm blocks git-dependency
build scripts by default):
onlyBuiltDependencies:
- "@lanlinling/llm-providers"Does it read API keys from my environment?
No. Nothing in this package touches process.env for credentials (the
only process.env reads are AWS's own AWS_REGION/BEDROCK_REGION
convention for Bedrock, and log-level config). You always pass apiKey
explicitly — this is deliberate, so the package never silently depends on
an env var name you didn't choose.
If you want the common "load from .env and pass it in" pattern:
import 'dotenv/config'; // or your own .env loader
import { getModel } from '@lanlinling/llm-providers';
import { generateText } from 'ai';
const { model } = getModel({
providerId: 'anthropic',
modelId: 'claude-sonnet-4-6',
apiKey: process.env.ANTHROPIC_API_KEY!,
baseUrl: process.env.ANTHROPIC_BASE_URL, // optional, provider default otherwise
});
const result = await generateText({ model, prompt: 'Reply with exactly one word: pong' });
console.log(result.text);This is exactly the call this package was smoke-tested with (real Anthropic API call, live response).
Usage
import { getModel, getAllModels, getProvider, PROVIDERS } from '@lanlinling/llm-providers';
// List every built-in provider + its models
for (const { provider, models } of getAllModels()) {
console.log(provider.name, models.map((m) => m.id));
}
// Look up one provider's metadata (default base URL, whether it needs a key, etc.)
console.log(getProvider('deepseek'));
// Get a ready-to-use Vercel AI SDK LanguageModel for any provider
const { model, modelInfo } = getModel({
providerId: 'deepseek',
modelId: 'deepseek-chat',
apiKey: process.env.DEEPSEEK_API_KEY!,
});PROVIDERS is a plain mutable object — extend it at startup if you need a
provider that isn't built in, or just pass providerType explicitly in
getModel()'s config to skip the registry lookup entirely.
See TROUBLESHOOTING.md for provider-specific gotchas (proxy base-URL formats, custom providers, etc.).
