Cost and token control
Built today
Section titled “Built today”- Not every step is an LLM call. Script, tool, condition, retrieve, report and notify nodes run without a model. A well-designed workflow spends tokens only on agent nodes.
- Lightweight versus heavyweight execution. A full coding harness and a cloned workspace are created only
for the step that needs them, behind a
conditionif you want. - Bounded context.
retrievetakestop_k, and tool outputs pass through projections so agents get the fields they need rather than whole API payloads. - Budgets. Agent steps accept
max_output_tokens,max_tool_callsandmax_cost_usd; profiles acceptmax_turns. The run plan says whether each cap is enforced or only estimated. - Spend limits per workspace or workflow, per day or month, with alerts.
- Honest accounting. Cost is shown only when pricing is known; otherwise it is unavailable, and spend limits say they are a lower bound.
- Prompt caching on the Anthropic system prompt, with cache read and write tokens recorded.
- Token-saving rules for OpenCode (optional) and the DCP pruning plugin (optional). See Workers.
Usage record per turn
Section titled “Usage record per turn”Input, output, cache read, cache write and reasoning tokens.
Where the price comes from
Section titled “Where the price comes from”For OpenAI models, highest priority first:
- The profile’s
pricing(input and output prices both set). AZHI_OPENAI_RATESon the server, for examplegpt-5.5=5/0.5/30,my-model=1/4(model=input/cached/outputorinput/output, USD per million tokens).- The cost OpenCode reports from its model catalog (OpenCode steps).
- The built-in standard-tier table in
src/agents/openai-pricing.ts.
A model with no rate is shown as cost unavailable, never guessed. Check the provider’s pricing page before relying on the built-in table.
Subscriptions
Section titled “Subscriptions”| Plan | Cost shown |
|---|---|
| ChatGPT plan | 0, labelled reported, “ChatGPT plan”. Token counts are still recorded |
| GitHub Copilot | Counted in AI credits against the monthly pool. azhi copilot quota and the run page show your allowance. Rates come from published tables |
Vision, not built
Section titled “Vision, not built”Request → cached result? (vision: result cache) → deterministic step possible? (today: chosen by the author, not the runtime) → small model sufficient? (vision: capability routing) → retrieve only the context needed (partly built: top_k, projections) → large model only if necessary- Automatic model selection by capability and strategy (
capability: coding,strategy: cost_optimized). Today the profile names a provider and model. - Result caching across runs.
- Savings reporting against a naive all-agent baseline. Azhi reports only measured cost until a defined baseline exists per workflow. Any “saved $X” figure would need that baseline to be honest.