SDK — Costs
The rivano.costs resource gives you detailed cost attribution, budget controls, and SLA enforcement across your AI workloads.
Cost breakdown
costs.breakdown() returns cost data sliced by agent, by model, and by day:
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const breakdown = await rivano.costs.breakdown({
startTime: '2026-03-01T00:00:00Z',
endTime: '2026-04-01T00:00:00Z',
});
console.log('Total:', `$${breakdown.total}`);
for (const agent of breakdown.byAgent) {
console.log(`Agent ${agent.agentName}: $${agent.cost}`);
}
for (const model of breakdown.byModel) {
console.log(`Model ${model.modelName}: $${model.cost}`);
}
for (const day of breakdown.daily) {
console.log(`${day.date}: $${day.cost}`);
} Breakdown filter parameters
| Parameter | Type | Description |
|---|---|---|
startTime | string | ISO 8601 start of range |
endTime | string | ISO 8601 end of range |
agentId | string | Scope to a single agent |
environment | string | Scope to an environment |
Budgets
Budgets alert you when cost crosses a threshold within a billing period.
List budgets
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const { data } = await rivano.costs.budgets.list();
for (const budget of data) {
console.log(`${budget.name}: $${budget.amount} / ${budget.period}`);
}
Create a budget
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const budget = await rivano.costs.budgets.create({
name: 'Monthly production cap',
amount: 500,
period: 'monthly',
alertChannelId: 'channel_slack_ops',
});
console.log('Budget created:', budget.id); Budget create parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the budget |
amount | number | Yes | Dollar threshold |
period | 'daily' | 'weekly' | 'monthly' | Yes | Reset cadence |
alertChannelId | string | No | Alert channel to notify when threshold is crossed |
Delete a budget
await rivano.costs.budgets.delete('budget_abc123');
SLA policies
SLA policies enforce latency and quality thresholds. Violations are recorded and available for reporting.
List SLA policies
const { data } = await rivano.costs.sla.list();
Create an SLA policy
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: 'rv_...' });
const sla = await rivano.costs.sla.create({
name: 'Production P99 latency',
metric: 'p99_latency_ms',
threshold: 2000,
});
console.log('SLA created:', sla.id);
Get SLA violations
const violations = await rivano.costs.sla.violations();
for (const v of violations) {
console.log(`${v.slaName}: ${v.actualValue} (limit ${v.threshold}) at ${v.occurredAt}`);
}
⚠
Budget alerts fire asynchronously — there is no hard cap that blocks requests. If you need to stop spending, disable the agent via the dashboard or SDK.
Error handling
| Error | When it occurs |
|---|---|
SdkAuthError | Invalid API key |
SdkNotFoundError | Budget or SLA ID does not exist |
SdkError | Invalid amount or period |
Related
- SDK Alerts — Configure alert channels for budget notifications
- SDK Traces — Per-trace cost fields (
costUsd) - SDK Billing — Plan status and subscription management