Quickstart
Deploy one feature and record your first charge.
Prefer to have your coding agent do the setup? Copy the agent prompt.
Install
Install the SDK in your application:
npm install orbytelabsThe package includes the server SDK and CLI.
Connect your project
From your application directory:
npx orbytelabs login
npx orbytelabs linkSelect an organization, application, and Development environment. The CLI can
create them for you. It saves the link in .orbyte/project.json and adds
.orbyte/ to .gitignore.
Define a feature
Create orbyte.config.ts:
import { count, credits, defineConfig, feature } from "orbytelabs";
export default defineConfig({
features: {
requests: feature("API requests", credits("0.01"), count()),
},
});Publish it to the linked environment:
npx orbytelabs deploy
npx orbytelabs grant 1 --identity customer_123 \
--idempotency-key welcome_customer_123
npx orbytelabs api-key create --name "Usage server"The grant adds one credit without collecting payment. Save the key's one-time
secret as ORBYTE_API_KEY in your server environment. The CLI's saved login is
separate from this key.
Check and track
Run on your server after loading ORBYTE_API_KEY:
import { balance, check, track } from "orbytelabs";
const identity = "customer_123";
const access = await check("requests", identity);
if (!access.allowed) throw new Error(access.reason);
// Perform the billable work here.
await track("requests", identity, undefined, {
idempotencyKey: "request_123",
});
const result = await balance(identity);
console.log(result.availableCredits); // 990000000n = 0.99 creditsRepeat with the same key and unchanged input to retry that event without charging again. Use a new key for each new event. Checks reserve no funds; handle tracking failure even after an allowed check.
Open the customer in the dashboard to inspect the balance and ledger. Next, add a plan or a pricing rule.
