Team working on a SaaS product
SaaS teams shipping AI to their own users

Embed paid AI features in your SaaS

Top up balance. Pay an inference fee on routed usage.
  • Hide prompts and provider keys behind named features
  • Mint short-lived runtime sessions for each end user
  • Meter invocations and tokens per workspace and feature
  • Prepaid owner balance burns down as your users call features
SDK quickstart
keystash-sdk
import { createApiKeySdk } from "keystash-sdk";

const sdk = createApiKeySdk({
  baseUrl: "https://api.keystash.dev"
});

await sdk.account.connect(process.env.KEYSTASH_APP_KEY!);

const session = await sdk.runtime.sessions.create({
  spaceId: "acme-prod",
  endUserId: "user_123",
  operationIds: ["summarize_ticket"]
});

const result = await sdk.runtime.invoke({
  operationId: "summarize_ticket",
  input: {
    ticket: "Customer asks for refund after duplicate charge."
  }
}, session.token);
Runtime response
{
  "operationId": "op_01",
  "operationSlug": "summarize_ticket",
  "model": "openai/gpt-5.4-mini",
  "outputText": "Duplicate charge. Refund likely. Escalate billing.",
  "usage": {
    "inputTokens": 212,
    "outputTokens": 36,
    "totalTokens": 248
  }
}
Workspace
acme-prod
Feature
summarize_ticket
Hidden prompt, fixed model
Session
user_123
Short-lived runtime token
This month
18,240 calls
4.8M tokens
Billing
Prepaid balance
Top up, then burn down with usage
Define
  • One feature per product action
  • Provider key stays server-side
  • Prompt stays hidden
Run
  • Mint runtime sessions per end user
  • Invoke features from browser or app shell
  • Keep models and prompts scoped
Meter
  • Track calls and token usage by workspace
  • Track usage by feature
  • Debit owner balance as users run features

SDK first

  • `sdk.spaces.operations.create(...)`
  • `sdk.runtime.sessions.create(...)`
  • `sdk.runtime.invoke(...)`
  • `sdk.runtime.usage(...)`
Browser-safe flow
App key mints a short-lived runtime session. Runtime session invokes one or more named features.
Hidden prompts
Prompt templates live in KeyStash. The browser only sends feature input.
Pricing
Top up owner balance, then KeyStash burns it down with an inference fee on routed usage.
Create feature
Admin
const feature = await sdk.spaces.operations.create("acme-prod", {
  title: "Summarize ticket",
  slug: "summarize_ticket",
  model: "openai/gpt-5.4-mini",
  systemPrompt: "You summarize support tickets for internal agents.",
  userTemplate: "Ticket:\n{{ticket}}\n\nReturn a concise summary.",
  monthlyInvocationLimit: 10000,
  allowedOrigins: ["https://app.acme.com"]
});
Dashboard preview
summarize_ticket
openai/gpt-5.4-mini
active
Calls
12,842
Tokens
3.2M
Runtime sessions
TTL 15 min
Origin lock app.acme.com
What ships now
  • Workspaces
  • App keys
  • Hidden features
  • Runtime sessions
  • Invocation metering
  • Inference-fee billing