@demystify/gateway-sdk
v0.3.0
Published
TypeScript SDK for the dmstfy-gateway data plane (chat, embeddings, STT, TTS via one OpenAI-compatible endpoint)
Readme
@demystify/gateway-sdk
TypeScript client for the dmstfy-gateway data plane — a multi-tenant, OpenAI-compatible AI gateway with virtual keys, per-tenant rate limits, micro-USD budget ledgers, and usage metering.
Part of the Demystify Core Services suite. The client speaks the wire contract the gateway's mock and live backends share, so code written against the offline mock runs unchanged against a real deployment.
Install
npm add @demystify/gateway-sdk
# or: pnpm add @demystify/gateway-sdkQuickstart
import { createGatewayClient } from "@demystify/gateway-sdk";
const client = createGatewayClient({
baseUrl: "http://localhost:8080",
key: "dmk_your_virtual_key",
product: "my-app",
});
const res = await client.chat({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(res.choices[0].message.content);
console.log("cost µUSD:", res.usage?.cost_micro_usd);API surface
| Symbol | Purpose |
| --- | --- |
| createGatewayClient → GatewayClient | Chat, embeddings, transcribe, speak |
| GatewayError / GatewayErrorCode | Typed errors carrying the gateway error taxonomy code |
| ChatOptions, EmbedOptions, TranscribeOptions, SpeakOptions | Request types |
| ChatCompletion, EmbeddingsResponse, TranscriptionResult, SpeechResult, Usage | Response types |
Inject a custom fetchImpl to run the client in-process against the moat (see
the suite scenarios) or through any transport.
See the module README for the full endpoint and admin/control-plane reference.
Versioning & compatibility
Pre-1.0 semver: a 0.x minor may contain breaking changes, a patch never does —
pin ~0.x.y. The SDK requires a gateway service on the same 0.x minor; the
gateway rejects unknown request fields with invalid_request. Full policy
(including the deprecated-header window):
versioning-policy.md.
Changes: CHANGELOG.md.
License
MIT © Demystify Systems
