npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devicai/model-gateway-sdk

v0.1.0

Published

Experimental multi-provider LLM SDK (OpenAI client first) that meters BYOK usage against Devic tenant/subtenant limits

Downloads

155

Readme

@devicai/model-gateway-sdk

Experimental. A multi-provider LLM SDK that meters your usage against Devic's tenant/subtenant usage limits — the same engine Devic uses internally for its own assistants and agents. OpenAIClient is the first client this package exports; more provider clients (Anthropic, Gemini, ...) will be added as they're integrated, sharing the same metering/error contract.

You keep using your own provider API key (BYOK) exactly as before. Devic's gateway never stores it — it only forwards your request to the provider and records how many tokens/what it cost against your tenant.

Why a wrapper, not a fork

OpenAIClient extends the official openai package's OpenAI class. It only overrides baseURL and defaultHeaders in the constructor — every resource (chat.completions, embeddings, responses, ...) is the untouched implementation from openai. Whatever OpenAI ships next keeps working here without any changes to this package.

Install

npm install @devicai/model-gateway-sdk openai

Usage

import { OpenAIClient, isTenantLimitExceeded } from '@devicai/model-gateway-sdk';

const client = new OpenAIClient({
  apiKey: process.env.OPENAI_API_KEY,     // your real OpenAI key — sent to OpenAI as usual
  devicApiKey: process.env.DEVIC_API_KEY, // devic-xxx
  // tenantId: 'acme-corp',               // optional: attribute/limit usage to a Devic tenant
  // subtenantId: 'user-123',             // optional: per-end-user limits within the tenant
});

try {
  const completion = await client.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{ role: 'user', content: 'Hello!' }],
  });

  console.log(completion.choices[0].message);
  console.log(completion.devic?.usage); // [{ metric: 'tokens', limit, current, percent, resetsAt }, ...]
} catch (err) {
  if (isTenantLimitExceeded(err)) {
    console.error(`Tenant limit hit, resets in ${err.error.retryAfter}s`);
    return;
  }
  throw err;
}

Scope (v1) — this is an experiment

  • OpenAIClient only. Other provider clients are planned but not implemented yet.
  • tenantId is optional. Without it, requests still go through the gateway (BYOK passthrough) but no tenant usage limits are checked or recorded — useful for call sites that don't need tenant scoping yet while keeping the same SDK everywhere.
  • No streaming. stream: true requests are rejected by the gateway with a 400. Non-streaming JSON endpoints (chat completions, embeddings, the responses API, ...) all work, since the gateway is a generic passthrough rather than endpoint-specific logic.
  • BYOK. Devic never custodies your provider API key.

Planned next, not yet implemented: streaming support, additional provider clients.

How it works

This package only changes where requests go and what headers accompany them — see the model-gateway service for the actual metering logic (API key resolution, tenant limit checks, usage recording, cost calculation).