OPEN SOURCE · v2.3.1 · MPL-2.0 · NODE.JS >= 22
One calling contract for every LLM provider.
@ubinity/node-llm is a lightweight, zero-bloat Node.js (>=22) library that normalizes OpenAI, OpenAI-compatible servers (DeepSeek, Qwen, Ollama), Anthropic, and Google Gemini / Vertex AI into one request format, one OpenAI-compatible response shape, and one typed NodeLlmError — supporting both API keys and official subscription CLIs.
$ 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); Why Engineers Use @ubinity/node-llm
API Key OR Official Subscription (auth: "subscription")
Use standard API keys via optional peer SDKs, or pass auth: "subscription" to run official headless clients (Claude Code, Codex, Antigravity CLI) with API-key env vars stripped to prevent accidental API billing — including WSL execution from Windows.
Strict Contract, Never Silent Drops
Unsupported parameters (such as tools or temperature on subscription calls, or streaming in contract v1) fail fast with a typed NodeLlmError ("unsupported") instead of being silently ignored.
Production Resilience Built In
Exponential backoff retries honoring Retry-After, AbortSignal & total timeout budgets, LRU client pooling, unified prompt caching (cache), reasoning effort scale, and standardized 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) |
Explicit Design Boundaries (Contract v1)
- Requires Node.js 22 or later; provider SDKs (openai, @anthropic-ai/sdk, @google/genai) are optional peer dependencies.
- Returns one complete normalized reply per call. Streaming (stream: true) and multi-choice (n > 1) are intentionally refused in contract v1.
- Full API reference, error codes, and changelog are maintained canonically in the GitHub repository.
Built with the same deterministic engineering principles behind Ubinity Prompt Vault and Ubinity Ledger .