Resources

One SDK: server billing, client UI, model tracking.

@crediball/sdk wraps your actions and bills credits. @crediball/react and @crediball/elements render the UI. Nothing gets priced in code — the dashboard owns that.

Install

npm install @crediball/sdk
npm install @crediball/react
# or @crediball/elements for a framework-agnostic build

@crediball/sdk — server-side billing

Initialize once with your secret key, then wrap every action worth billing. Crediball auto-discovers new actions; you price and activate them from the dashboard, not in code.

import crediball from "@crediball/sdk";

crediball.init(process.env.CREDIBALL_API_KEY!);

const poem = await crediball.action("generate_poem", userId, () =>
  generatePoem(topic)
);

No result to wrap? Use crediball.track(action, userId)instead — same billing, no return value. When you’re done wrapping, run npx @crediball/sdk sync once so every action shows up on the dashboard immediately, ready to price, instead of only after a user triggers it.

@crediball/sdk/ai — model usage tracking

Wrap your model client — wrapOpenAI, wrapAnthropic, wrapGemini, or crediballMiddleware for the Vercel AI SDK — and call it inside a crediball.action()callback. Provider, model, and token usage show up automatically on your dashboard’s Models page, without any pricing table or model manifest in your code.

@crediball/react — drop-in credit UI

One provider, three tiers of components, all reading the same live data: fully-styled drop-ins (<CreditsBadge/>, <PaywallModal/>, <ActionCostList/>), small themeable variables you place inline (<CrediballBalance/>, <CrediballTopUpButton/>), and a headless useCrediball() hook for full control. Not using React? @crediball/elements ships the same three tiers as framework-agnostic web components.

MCP server

Crediball also runs an MCP server at /api/mcp, so an AI coding agent can finish setup in the same conversation as the integration: list discovered actions, price and activate them, create top-up packages, set a signup bonus, and flip the app to live — all without a human clicking through the dashboard.

Full reference

The complete, always-current integration guide — including every method, the sandbox vs. live model, and the model-attribution rules — lives at crediball.ai/llms.txt, written for both humans and coding agents to read directly.

Get started