Cost Tracking
Rivano calculates the cost of every proxied request using your provider’s pricing model. You get per-agent cost breakdowns, budget alerts, and SLA monitoring without any code changes in your application.
Step 1: Configure provider pricing
Rivano uses standard pricing for major providers out of the box. If you use a custom deployment or negotiated pricing, update the provider record:
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: process.env.RIVANO_API_KEY! });
await rivano.providers.create({
name: 'openai-custom',
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
pricing: {
'gpt-4o': {
inputCostPer1kTokens: 0.0025,
outputCostPer1kTokens: 0.01,
},
'gpt-4o-mini': {
inputCostPer1kTokens: 0.00015,
outputCostPer1kTokens: 0.0006,
},
},
}); Step 2: View cost breakdown
Cost data is available in Observability → Costs → Breakdown. The breakdown shows total spend grouped by agent, model, and time period.
Query cost data via the API:
const breakdown = await rivano.costs.breakdown({
period: '30d',
groupBy: 'agent',
});
for (const entry of breakdown.data) {
console.log(`${entry.agentName}: $${entry.totalCostUsd.toFixed(4)}`);
} Step 3: Create budgets
Set a budget to get alerted when an agent approaches its spending limit:
await rivano.costs.createBudget({
name: 'customer-support-monthly',
agentId: 'agent_abc123',
period: 'monthly',
limitUsd: 500,
}); Rivano sends an alert when usage reaches 80% and 100% of the budget. At 100%, you can optionally configure the budget to block further requests from that agent for the remainder of the period.
Create a budget for each production agent. It takes 30 seconds and prevents surprise bills.
Step 4: Set up alerts
Configure where budget and SLA alerts are delivered:
# Via the dashboard: Settings → Alerts → + Alert Channel
# Choose: email, webhook, or Slack webhook
# Via API (webhook example):
curl -X POST https://api.rivano.ai/api/alert-channels \
-H "Authorization: Bearer rv_api_..." \
-H "Content-Type: application/json" \
-d '{
"name": "ops-webhook",
"type": "webhook",
"url": "https://hooks.example.com/rivano-alerts",
"events": ["budget.threshold_80", "budget.threshold_100", "sla.violation"]
}'
Step 5: SLA monitoring
Create SLA targets for latency and error rate:
await rivano.costs.createSla({
name: 'customer-support-sla',
agentId: 'agent_abc123',
p99LatencyMs: 3000,
errorRatePercent: 1.0,
evaluationPeriod: '1h',
}); View active violations:
curl "https://api.rivano.ai/api/costs/sla/violations?period=24h" \
-H "Authorization: Bearer rv_api_..."
Worked example: monitor a new agent
import Rivano from '@rivano/sdk';
const rivano = new Rivano({ apiKey: process.env.RIVANO_API_KEY! });
// 1. Register the agent
const agent = await rivano.agents.create({
name: 'invoice-processor',
modelProvider: 'anthropic',
modelName: 'claude-opus-4-5',
environment: 'production',
});
// 2. Set a monthly budget
await rivano.costs.createBudget({
name: 'invoice-processor-budget',
agentId: agent.data.id,
period: 'monthly',
limitUsd: 200,
});
// 3. Set an SLA target
await rivano.costs.createSla({
name: 'invoice-processor-sla',
agentId: agent.data.id,
p99LatencyMs: 5000,
errorRatePercent: 2.0,
evaluationPeriod: '1h',
});
console.log('Agent monitoring configured');
Related
- Costs API — Full REST reference for budgets and SLA
- Observability Dashboard — Costs page walkthrough
- SDK Costs — Full SDK costs resource reference