ssimplifi-prism
v1.8.0
Published
Node SDK for Prism by Ssimplifi — the AI gateway that picks the model for you.
Maintainers
Readme
ssimplifi-prism — Node SDK for Prism
npm install ssimplifi-prismQuick start
import { Prism } from "ssimplifi-prism";
const client = new Prism({ apiKey: process.env.PRISM_API_KEY! });
const response = await client.chat.completions.create({
messages: [{ role: "user", content: "What's the capital of Australia?" }],
mode: "balanced",
});
console.log(response.choices[0].message.content);That's it. The SDK extends the official OpenAI Node SDK, pointed at Prism's base URL. Everything you already know about openai — streaming, retries, response shape — works identically.
Prism-specific kwargs
| Field | Header | What it does |
|---|---|---|
| mode: "eco" \| "balanced" \| "sport" | X-Prism-Mode | Quality/cost mode for auto-routing |
| model_prefer: "claude-sonnet" | X-Prism-Model-Prefer | Force a specific model |
| session_id: "user-abc" | X-Prism-Session | Multi-turn memory |
| cache: "off" \| "exact" \| "semantic" | X-Prism-Cache | Cache behavior for this request |
| request_tags: { feature: "search" } | X-Prism-Request-Tags | Attribution tags for usage breakdown |
// Multi-turn chat with session memory
await client.chat.completions.create({
messages: [{ role: "user", content: "Remember: my name is Ravi" }],
session_id: "user-abc",
});
// Next call — no need to resend history
const r = await client.chat.completions.create({
messages: [{ role: "user", content: "What's my name?" }],
session_id: "user-abc",
});
console.log(r.choices[0].message.content); // "Your name is Ravi."Admin methods (Pro/Team tier)
// Live model catalog
const catalog = await client.models.list({ provider: "groq" });
console.log(catalog.summary);
// Your usage
console.log(await client.usage.summary({ days: 7 }));
// Cache stats
console.log(await client.cache.stats({ days: 7 }));
// API keys
console.log(await client.keys.list());
const newKey = await client.keys.create({ name: "staging-app" });
console.log(newKey.key); // full secret shown ONCE
await client.keys.revoke("key-id-from-list");
// Identity + balance
console.log(await client.whoami());
console.log(await client.balance());Drop-in replacement for plain OpenAI
// Before
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// After
import { Prism } from "ssimplifi-prism";
const client = new Prism({ apiKey: process.env.PRISM_API_KEY! });Every client.chat.completions.create(...) call you already wrote continues to work. Add mode: and you've got auto-routing + caching + multi-provider failover.
Compatibility
- Node 18+
- Builds on
openai@^4.50.0 - Tied to the Prism backend
/v1/major version — SDK 1.x works with any backend 1.x.
License
Apache-2.0
