Skip to main content
@stigg/agent-sdk-js adds gating, metering and budgets to the LLM calls your agents make. See AI agents for setup, and the source on GitHub.
npm also lists versions 1.0.0, 1.0.1, 1.1.0 and 2.0.0. Those are pre-release builds published before the package was re-versioned, and they aren’t supported. Install 0.1.0 or later.
2026-11-12
  • Updated @stigg/node-server-sdk to 6.4.3, which stops memory growing with every usage and event report. See the Node.js SDK changelog.
2026-11-10
xAI, Together AI, Fireworks AI and DeepSeekSee xAI, Together AI, Fireworks AI and DeepSeek.
  • Added: xaiRecipe, togetherRecipe, fireworksRecipe and deepseekRecipe, matched on each provider’s API host. They cover chat completions on all four, the Responses API on xAI, Together AI and Fireworks AI, and messages.create through an Anthropic client on Fireworks AI and DeepSeek.
  • Changed: a detected client keeps its openai.* or anthropic.messages.create event names and adds a provider dimension of xai, together, fireworks or deepseek. Pass the recipe at wrap, for example wrap(client, { recipe: xaiRecipe }), to report under xai.*, together.*, fireworks.* or deepseek.* instead.
  • Added: xAI calls report cost_in_usd_ticks, xAI’s exact price, as an integer at 10,000,000,000 ticks to the dollar. A meter that sums it should divide by that scale, or one of your choosing, rather than price each tick. They also report reasoning_tokens and num_sources_used, and on the Responses API num_server_side_tools_used and a count per server-side tool, such as web_search_calls and x_search_calls.
  • Changed: xAI’s normalized output tokens include reasoning tokens. xAI counts them outside completion_tokens but inside total_tokens, so output is the total minus the input. completion_tokens is reported as xAI stated it.
  • Added: Together AI chat calls report cached_tokens when a model states its cache reads flat, as usage.cached_tokens.
  • Added: DeepSeek chat calls report reasoning_tokens, and the prompt_cache_hit_tokens and prompt_cache_miss_tokens DeepSeek prices on, whether the response nests them or not. The hit and miss counts add up to prompt_tokens, so price the split or the total, not both.
  • Note: a streamed messages.create on Fireworks AI or DeepSeek states its counts on the final message_delta. A stream that ends before then reports what it has and is flagged incomplete.
  • Note: Together AI, Fireworks AI and DeepSeek state no price, so their calls report tokens only.
vLLMSee vLLM.
  • Added: vllmRecipe({ baseUrl }), for a self-hosted vLLM server reached through an OpenAI client. It’s opt-in, because a vLLM server has no hostname to recognize it by. Named at wrap, it reports chat completions and the Responses API as vllm.*, and wrap refuses a client pointed at any other server, so a mistyped URL fails at setup. A vLLM client that doesn’t name the recipe still reports as openai.*.
    • Note: cached_tokens is reported only when the server runs with --enable-prompt-tokens-details.
Claude on Bedrock through Anthropic’s clientSee Amazon Bedrock.
  • Changed: AnthropicBedrock and AnthropicBedrockMantle clients from @anthropic-ai/bedrock-sdk are matched by bedrockRecipe(), on Bedrock runtime and Mantle hosts, including FIPS, China and PrivateLink vpce- endpoints. They keep the anthropic.messages.create event name and Anthropic’s counters, total_tokens included, and add provider: bedrock. Pass wrap(client, { recipe: bedrockRecipe() }) to report bedrock.messages.create instead.
    • Note: a PrivateLink endpoint on a private DNS name of your own isn’t recognized. Name the recipe for it.
    • Note: beta.messages on these clients isn’t governed.
2026-11-08
PerplexitySee Perplexity.
  • Added: perplexityRecipe(), matched on api.perplexity.ai, for Perplexity’s own client and an OpenAI client pointed at its Agent API. It covers responses.create and chat.completions.create, buffered and streamed.
  • Added: Perplexity calls report total_cost, the price Perplexity stated for the call, in micro-dollars by default. It includes per-call tool fees such as web_search, which token counts don’t cover. Set unitsPerDollar to change the scale.
    • Note: OpenRouter and LiteLLM report their price as cost. A meter that prices all three needs both names.
  • Added: the Agent API’s cache counts, cache_read_input_tokens and cache_creation_input_tokens, and on chat completions reasoning_tokens, citation_tokens and num_search_queries.
  • Changed: a detected Perplexity client keeps its openai.responses.create and openai.chat.completions.create event names and adds a provider: perplexity dimension, unless the run already sets provider. Pass wrap(client, { recipe: perplexityRecipe() }) to report under perplexity.* instead.
  • Note: search.create, embeddings, async.chat.completions, batches and browser sessions aren’t gated. A responses.create with background: true is gated but not metered.
2026-11-08
  • Updated @stigg/node-server-sdk to 6.4.1, which fixes checks that stayed denied after usage went back under a hard limit. See the Node.js SDK changelog.
2026-11-04
TrueFoundry AI Gateway
  • Added: truefoundryRecipe(), for TrueFoundry’s AI Gateway, hosted or self-hosted. OpenAI and Anthropic clients pointed at the gateway report under truefoundry.* event names, with token counts and the model that served. That model comes from TrueFoundry’s x-tfy-resolved-model header, so a call the gateway sent to a fallback model reports the one that answered. For a self-hosted gateway, pass its base URL with wrap(client, { recipe: truefoundryRecipe({ baseUrl }) }). stigg.wrapFetch takes the recipe too.
  • Changed: OpenAI and Anthropic clients whose base URL is on truefoundry.ai, truefoundry.cloud or truefoundry.com now report as truefoundry.*, where they previously reported as openai.* or anthropic.*.
  • Note: TrueFoundry’s Gemini, Bedrock and Azure OpenAI passthroughs aren’t covered.
2026-11-04
Vercel AI SDKSee Tools.
  • Added: paid tools. stiggVercelMiddleware() takes the same tools option as the LangChain handler, and middleware.tools() wraps each listed tool’s execute. A tool is checked before it runs and reported after it succeeds, as the model step that asked for it. A denied tool doesn’t run, and the model gets a short error as its result.
  • Added: a tool with needsApproval names its customer in its own context, toolsContext in ai 7 or experimental_context in ai 6.
2026-11-04
AI gatewaysSee agentgateway and A gateway you call over HTTP.
  • Added: agentgatewayRecipe(), for the open-source agentgateway and the builds on it, Solo.io’s enterprise edition and Gloo AI Gateway. Calls report under agentgateway.* event names, with token counts and the model that served. Pass the gateway’s baseUrl, which Solo.io and Gloo builds require.
  • Added: stigg.wrapFetch({ baseUrl, recipe }), which returns a fetch that checks and meters plain HTTP calls to a gateway, the same way a wrapped client does. Any recipe for OpenAI’s or Anthropic’s format works.
Usage governance
  • Added: register() with a budget that sets no limit gives an agent with no budget yet one with no limit, resetting monthly unless you pass a cadence. Its usage is tracked without a cap, and an existing budget, including a limit set in the Stigg app, is left as it is. See Observe-only rollout.
AUDR reportingSee Reporting usage in AUDR format.
  • Added: the audr option. Pass audr: { client, environment } to the constructor and the SDK also writes an AUDR record (Agent Usage Detail Record) for every model call it meters, to your own @openaudr/audr client. Off by default. @openaudr/audr is an optional peer dependency, at >=0.2.0 <0.3.
2026-11-03
Vercel AI SDKSee Vercel AI SDK.
  • Added: stiggVercelMiddleware(), a language model middleware for the AI SDK’s wrapLanguageModel. Each model call of generateText, streamText or an agent’s loop is checked before it runs, and its usage is reported after, as the agent in the middleware’s stiggContext. Works with ai 6 and 7.
  • Added: a call names its customer in providerOptions.stigg, which is removed before the provider sees the call.
  • Added: a streamed call is reported once, when the stream ends. A stream the user stops is reported from an estimate of its output and isn’t counted as a metering failure. A timeout, a failed stream, or a model that reports no usage, streamed or not, is estimated and counted as one.
2026-10-29
Google ADKSee Google ADK.
  • Added: StiggAdkPlugin, from the new @stigg/agent-sdk-js/adk entry point. Add it to a Runner’s plugins to govern every agent the Runner runs. Each model call and tool call is checked before it runs, and its usage is reported after it succeeds, as the agent ADK runs it under. @google/adk 2.x is an optional peer dependency.
  • Added: stepContext, a function that returns each step’s stiggContext, usually the customer. ADK has no per-run metadata, so this is where the customer comes from. Resolve it from your server’s login, never from a client-supplied userId or state.
  • Added: onRefusal. ADK doesn’t let a plugin throw, so a refused model call returns an answer instead. Return { transferTo: 'agent-name' } to hand the turn to another agent, or nothing for an error response with errorCode: 'STIGG_ACCESS_DENIED'. A refused tool returns a short error as its result, and the model carries on without it.
  • Added: plugin.denialOf(event), which returns the decision behind a refused step’s event.
  • Put the plugin first in plugins. ADK stops at the first plugin that answers a step, so a plugin before it can hide that step from Stigg.
2026-10-29
LangChain and LangGraphSee LangChain and LangGraph.
  • ⚠️ Changed: a run names its customer with metadata: { stiggContext: { customerId } }. metadata.stiggCustomerId still works, but it’s deprecated and logs a warning. A run that names two different customers, one in each field, throws.
  • Added: on invoke, the run’s stiggContext can set customerId and correlationId. Any other field throws, because a client can write that metadata. A node can set other fields in its own config’s metadata.stiggContext, and they apply to that node’s steps.
  • ⚠️ Changed: stigg.middleware() takes a step’s contexts as stiggContexts: [{ customerId }], outermost first. StepAttribution.customerId was removed, and a step that still passes it throws.
Agent budgets
  • Added: budget.scope on stigg.register(), a list of entity IDs that narrows a budget to the calls attributed to all of them. Use it for a budget per value of a dimension, such as one per model. Each scope is a separate budget, so register once per scope, and register the agent’s whole budget too.
  • Added: defaultPlanId on stigg.register(). A customer Stigg doesn’t know yet is created on that plan before the agent is registered. Without it, registering an agent for an unknown customer fails.
Other changes
  • ⚠️ Changed: a stiggContext field of the wrong type throws. For example, a non-string agentId, defaultPlanId or dimension value, or a usageMapper that isn’t a function. These were previously passed through.
2026-10-26
LangChain and LangGraph
  • Fixed: each step’s usage is reported as the nearest agent above it in LangChain’s run tree, not to the agent named in the run’s lc_agent_name metadata. Unnamed sub-agents inherit that metadata, and a caller can set it, so a step could count against the wrong agent or an agent the caller chose.
  • Added: rootAgent on StiggLangChainCallbackHandler, the agent the top-level run always counts as. Without it, the caller’s runName decides.
  • Fixed: a class-based tool such as TavilySearch, which starts without a name, is named from the model’s tool call or from its result. A priced tool’s usage is now reported even when its name arrives only with its result, and the SDK logs once that it ran unchecked.
  • Fixed: completion models, which aren’t chat models, are metered from LangChain’s llmOutput.tokenUsage. A streamed completion reports no usage, and that goes to onError rather than being reported as zero.
Customer provisioning
  • Fixed: a rate-limited or timed-out provisioning call no longer locks the customer out until the process restarts. Only unreachable, rate-limited and timed-out calls are retried, after 30 seconds. Every other refusal is final.
2026-10-26
LangChain and LangGraphSee LangChain and LangGraph.
  • Added: StiggLangChainCallbackHandler, from the new @stigg/agent-sdk-js/langchain entry point. Pass it in a run’s callbacks to govern a LangChain createAgent graph or a hand-built LangGraph StateGraph. Each model call and governed tool call is checked before it runs, and its usage is reported after it succeeds, as the agent that made it. @langchain/core 1.x is an optional peer dependency.
  • Added: stigg.middleware({ stiggContext, tools, hooks, agents }), the framework-neutral logic behind the handler, for wiring other orchestrators.
  • Added: the run’s customer comes from metadata.stiggCustomerId, or from a default customerId in stiggContext. A run with neither is refused before its first step. Set stiggCustomerId on your server, because it wins over the default.
  • Added: per-tool governance in tools, keyed by tool name, with '*' for every tool not named:
    • An entitlement: checked, then reported as one unit per call.
    • { entitlement, usage }: checked, then reported through a usage mapper over the call’s input and output.
    • { usage }: reported, never checked.
    • false: left ungoverned.
  • Added: agents, which gives each agent in the graph its own stiggContext and tools, laid over the shared ones. Point an agent’s agentId at an entity registered with stigg.register(), and its steps are checked and reported against that entity’s budget.
Other changes
  • Added: OpenTelemetry spans (stigg.check and stigg.ingest, with GenAI attribute names) from the middleware and the LangChain handler, so tracing tools such as Langfuse and LangSmith see Stigg’s decisions, including refusals. @opentelemetry/api is an optional peer dependency, and without it no spans are emitted. Wrapped clients emit no spans.
  • Changed: isAccessDenied finds an AccessDeniedError anywhere in an error’s cause chain or inside an AggregateError.
  • Added: HookContext carries the agent and tool a hook fired for.
2026-10-21
  • Added: defaultPlanId in stiggContext. A customer Stigg doesn’t know yet is created on that plan before their first check or report. An existing customer is left untouched.
    • Provisioning runs once per customer per process.
    • If Stigg is unreachable, the failure goes to onError and provisioning is retried on the next call. A check for a customer that couldn’t be provisioned follows checkErrorAction.
    • If Stigg refuses, for example because the plan doesn’t exist, the refusal is reported once and not retried.
2026-10-19
  • Fixed: the npm package links to the public stigg-agent-sdk-ts repository. It previously linked to a private one.
  • Fixed: the examples and .env.template use STIGG_SERVER_API_KEY, the variable the SDK reads. They previously used STIGG_API_KEY, which the SDK ignores. The examples still accept the old name.
2026-10-19
  • Fixed: a stream split with tee() is metered. Previously only for await was metered, so a teed Anthropic or OpenAI-compatible stream moved no budget.
  • ⚠️ Changed: wrap throws when stiggContext sets an idempotencyKey. One key shared by every call deduplicated them all down to the first, so later calls moved no budget. Set idempotencyKey per call instead.
  • ⚠️ Changed: a call throws when its customerId is empty or blank. It previously fell back to the client’s default customer. A call with no customerId still uses the default.
  • Fixed: apiKey is no longer enumerable on stigg.config, so logging or serializing the client no longer prints the key.
2026-10-19
  • Updated @stigg/node-server-sdk to 6.2.0. No change to the Agent SDK API.
2026-10-14
Databricks
  • Added: databricksRecipe, matched automatically on a Databricks workspace’s /serving-endpoints or /ai-gateway/mlflow/v1 URL. It covers both an OpenAI client pointed at the workspace and Databricks’ own @databricks/sdk-modelservingquery client, and emits databricks.chat.completions.create, databricks.responses.create and databricks.query.
  • Added: the model that answered is recorded as a dimension. On Databricks the model you send is a serving endpoint name, so the response is the only place the real model appears.
  • Added: databricksExternalRecipe for serving endpoints configured as external models, where the upstream provider charges you instead of Databricks. It emits databricks-external.* events. It’s opt-in, because the two routes look identical from the client: stigg.wrap(client, { recipe: databricksExternalRecipe() }).
  • Neither recipe reports a cost metric, because Databricks doesn’t state a price on any response. A workspace on a custom domain needs its base URL passed in: databricksRecipe({ baseUrl }).
Cloudflare
  • Added: cloudflareRecipe, matched automatically for both Workers AI (api.cloudflare.com/client/v4/accounts/<id>/ai/v1) and AI Gateway (gateway.ai.cloudflare.com). It covers an OpenAI client and the cloudflare package’s own ai.run, and emits cloudflare.chat.completions.create, cloudflare.responses.create, cloudflare.messages.create and cloudflare.ai.run.
  • Reports token counts only. Cloudflare doesn’t state a price or Neuron count on any response, so there’s no cost metric.
  • On AI Gateway, the model that served and the cf_aig_log_id are recorded as dimensions, and a cache hit isn’t metered because no one was charged for it.
  • Known limitation: a streamed ai.run call is gated but not metered, because Cloudflare returns raw SSE bytes for it.
2026-10-13
Initial release.Core
  • Added: StiggAgentSDK. Pass an API key, or one options object for the base URL, ingest mode and hooks.
  • Added: stigg.wrap(client, { stiggContext }), which returns a copy of a vendor client whose calls are checked and metered. The context names the customer, the agent the call is attributed to, and an optional entitlement. Naming an entitlement turns on gating. Without one, calls are metered but never refused. Any call can override the context in its own parameters, so one wrapped client can serve every customer.
  • Added: stigg.register() and stigg.deregister() to create an agent entity with a budget and a parent. Both are optional. Without them, checks and usage apply to the customer.
  • Added: a refused call throws AccessDeniedError. Pass it to stigg.denial(err) to get the decision, including which entity blocked the call and how to fix it.
  • Added: ingest: 'async' | 'sync'. Usage is reported as raw events by default. A metric named after a credit currency draws the credit balance directly. Metering failures go to the onError hook and never break the call.
  • Added: unitsPerTokens and weightedMetrics for pricing token counts in code. Stigg recommends reporting raw token counts and converting them in Stigg instead.
Providers
  • Added: Anthropic, OpenAI (Chat Completions and Responses), Google Gemini (models and chats), Groq, Mistral, Ollama and TypeSafe.
  • Added: any other OpenAI-compatible endpoint, metered under openai.* events.
Gateways
  • Added: OpenRouter, through an OpenAI client or OpenRouter’s own @openrouter/sdk. Reports cost and the model that served.
  • Added: LiteLLM. Reports cost from the response header and the model that served.
  • Added: Amazon Bedrock. Reports tokens only, because Bedrock doesn’t state a price.
  • Added: a gateway you operate yourself. The wrapped client sends attribution as x-stigg-* headers, and your gateway reports usage with stigg.ingestFromHeaders(...). This path meters but can’t refuse calls.