Skip to main content

Cost Management

Cost management in AxonFlow is for teams that want more than a monthly provider invoice. It gives you a way to define budgets close to the workloads that actually spend money, then surface or enforce those decisions in your governed AI flows.

For most production teams, that means answering questions like:

  • Which team or workflow is driving spend?
  • Can a runaway agent loop exceed its budget before anyone notices?
  • Should this request be blocked, warned, or downgraded when the budget is exhausted?
  • Can we keep evaluation teams productive without giving every agent unlimited spend?

Budget Scopes

AxonFlow budgets can be attached to the scopes that usually matter in multi-agent systems:

ScopeTypical use
organizationoverall company or platform cap
teamproduct team, business unit, or environment budget
agenta specific assistant or service account
workflowa governed workflow with known execution cost
userper-user or reviewer guardrails

That gives teams a practical hierarchy, even when the actual application architecture is messy.

Creating Budgets

Python SDK

from axonflow import (
AxonFlow,
CreateBudgetRequest,
BudgetScope,
BudgetPeriod,
BudgetOnExceed,
)

async def main():
async with AxonFlow(
endpoint="http://localhost:8080",
client_id="platform-team",
client_secret="replace-me",
) as client:
await client.create_budget(
CreateBudgetRequest(
id="platform-monthly",
name="Platform Team Monthly Budget",
scope=BudgetScope.TEAM,
scope_id="platform",
limit_usd=5000.0,
period=BudgetPeriod.MONTHLY,
on_exceed=BudgetOnExceed.WARN,
alert_thresholds=[50, 80, 100],
)
)

TypeScript SDK

import { AxonFlow } from '@axonflow/sdk';

const client = new AxonFlow({
endpoint: 'http://localhost:8080',
clientId: 'platform-team',
clientSecret: 'replace-me',
});

await client.createBudget({
id: 'code-reviewer-daily',
name: 'Code Reviewer Daily Budget',
scope: 'agent',
scopeId: 'code-reviewer',
limitUsd: 50,
period: 'daily',
onExceed: 'block',
alertThresholds: [80, 100],
});

The SDKs also expose check_budget / checkBudget so you can do a deliberate pre-flight decision in gateway-style or custom orchestration flows.

Enterprise Feature

Budget creation, check, and CRUD endpoints (/api/v1/budgets/*) require an Enterprise license. Community and Evaluation tiers have access to /api/v1/pricing (cost rate configuration) and /api/v1/usage (usage tracking) only.

Budget Actions

AxonFlow supports three actions when a budget is exceeded:

ActionMeaning
warnallow the request, but surface that a threshold was crossed
blockreject the request once the budget is exceeded
downgradeprefer a cheaper operating path where supported

These actions are useful because not every budget should behave the same way. A shared internal prototype may be allowed to warn. A customer-facing workflow with strict unit economics may need to block.

Automatic Enforcement In Proxy Flows

When requests are routed through AxonFlow, budget information can be attached to the response when a budget decision is relevant.

The response-level budget_info metadata includes fields such as:

  • budget_id
  • budget_name
  • used_usd
  • limit_usd
  • percentage
  • exceeded
  • action

That means your application can do more than just fail closed. It can:

  • show spend warnings to operators
  • route traffic differently when budgets are tight
  • explain to internal teams why a request was blocked

Pre-Flight Budget Checks

For workflows where you want an explicit decision before doing the expensive work, use a budget check:

from axonflow import AxonFlow, BudgetCheckRequest

async def main():
async with AxonFlow(
endpoint="http://localhost:8080",
client_id="platform-team",
client_secret="replace-me",
) as client:
decision = await client.check_budget(
BudgetCheckRequest(
team_id="platform",
agent_id="code-reviewer",
)
)

if decision.allowed:
print("safe to continue")
else:
print(decision.action, decision.message)

This is especially useful in multi-step orchestration where you want to stop before invoking an expensive provider, fan-out workflow, or analysis job.

Alerts And Forecasting Signals

Budgets support alert thresholds so teams can react before a hard stop:

  • 50% can notify a team lead
  • 80% can flag an environment or workflow as at-risk
  • 100% can block, warn, or downgrade depending on your operating model

That pattern works well for:

  • evaluation environments that should keep running but signal risk
  • production agents that need a hard cap
  • shared platform teams that want early warning rather than surprise outages

What A Staff Engineer Usually Designs Around

Budget controls become much more useful when they are attached to architecture decisions instead of added as a reporting afterthought. In practice, teams usually choose:

  • workflow budgets for expensive multi-step orchestration
  • agent budgets for long-running assistants
  • team budgets where several applications share the same platform account
  • user budgets when an internal product needs fairness or usage controls

That design work is one of the clearest signs that a pilot is maturing into a real platform.

Where Cost Governance Fits Best

The strongest use cases are not just "LLM cost tracking." They are:

  • multi-agent workflows where one user request can trigger several provider calls
  • shared internal platforms where many teams use the same governed AI fabric
  • enterprise environments where finance, platform, and engineering all need the same cost story
  • pilots that must prove they can scale without uncontrolled spend

This is also one of the cleanest upgrade stories in AxonFlow. Community gives you the primitives to structure spend and surface decisions. As usage becomes real and several teams share the system, Evaluation and Enterprise become more compelling because cost controls stop being optional hygiene and start becoming a platform requirement.