オープンソース · v2.3.1 · MPL-2.0 · NODE.JS >= 22
すべてのLLMプロバイダーを、ひとつの呼び出し契約で。
@ubinity/node-llm は、OpenAI・互換サーバー(DeepSeek / Qwen / Ollama)・Anthropic・Google Gemini / Vertex AI の呼び出しを単一のリクエスト形式・OpenAI互換レスポンス・統一エラー型(NodeLlmError)に正規化する軽量 Node.js(>=22)ライブラリです。APIキーに加え、公式CLI経由のサブスクリプション呼び出し(auth: "subscription")にも対応します。
$ npm install @ubinity/node-llm const { completion } = require('@ubinity/node-llm');
// Same calling contract for API keys or official subscriptions
const reply = await completion({
model: 'anthropic/claude-haiku-4-5',
auth: 'subscription', // or omit for API key
timeout: 120000,
messages: [
{ role: 'system', content: 'Answer in one concise sentence.' },
{ role: 'user', content: 'What is a vendored dependency?' }
]
});
console.log(reply.auth, reply.choices[0].message.content); エンジニアに選ばれる設計ポイント
APIキー & 公式サブスクリプション両対応
オプショナルな公式SDKでのAPIキー呼び出しに加え、auth: "subscription" を指定することで公式クライアント(Claude Code / Codex / Antigravity CLI)経由で実行可能。APIキー環境変数を隔離して意図しない従量課金を防ぎ、WindowsからのWSL実行にも対応します。
未対応パラメータを黙って無視しない厳格な契約
サブスク呼び出し時の未対応オプションや未実装機能は黙殺せず、即座に型付き NodeLlmError(code: "unsupported")で失敗させる設計により、本番での静かな挙動ズレを防ぎます。
本番運用向けの標準装備
Retry-After 準拠の指数バックオフ再試行、AbortSignal・タイムアウト管理、LRUクライアントキャッシュ、プロンプトキャッシュ(cache)、推論強度(effort)統一指定、Tool Calling 正規化を内蔵。
Supported Model Prefixes & Auth Modes
| Model Prefix | Protocol | Auth Modes |
|---|---|---|
| openai/ · gpt* | openai | API key or Codex CLI (subscription) |
| deepseek/ · qwen/ · dashscope/ | openai | API key |
| ollama/ · custom baseURL | openai | None / optional |
| anthropic/ · claude* | anthropic | API key or Claude Code CLI (subscription) |
| gemini/ · google/ | API key or Antigravity CLI (subscription) | |
| vertex_ai/ | vertex_ai | Google Cloud credentials |
| antigravity/<id> | subscription | Antigravity CLI (subscription only) |
明示的な設計境界(Contract v1)
- Node.js 22 以降が必要です。各プロバイダーSDKは必要なものだけ入れる optional peerDependencies 設計です。
- 1回の呼び出しにつき1つの完結した応答を返す契約です。stream: true や複数候補(n > 1)は現バージョンでは明示的に拒否されます。
- 完全なAPIリファレンスと変更履歴は GitHub リポジトリを唯一の正本(SSOT)として管理しています。
Built with the same deterministic engineering principles behind Ubinity Prompt Vault and Ubinity Ledger .