AgentForge

Cost Models

Built-in per-model cost tables for accurate budget tracking.

COST_MODELS

AgentForge includes a built-in cost table (COST_MODELS) for popular models:

import { COST_MODELS } from '@ahzan-agentforge/core';

CostModel

interface CostModel {
  inputPer1k: number;   // Cost per 1,000 input tokens (USD)
  outputPer1k: number;  // Cost per 1,000 output tokens (USD)
}

Supported Models

The COST_MODELS map includes pricing for:

ProviderModels
Anthropicclaude-opus-4-*, claude-sonnet-4-*, claude-haiku-*
OpenAIgpt-4o, gpt-4-turbo, gpt-3.5-turbo
Googlegemini-pro, gemini-1.5-flash

A default fallback model is used for unrecognized model names.

Usage

The BudgetGovernor uses cost models automatically. You can also use them directly:

const model = COST_MODELS['claude-sonnet-4-20250514'] ?? COST_MODELS['default'];
const cost = (inputTokens / 1000) * model.inputPer1k
           + (outputTokens / 1000) * model.outputPer1k;

Custom Models

For models not in the built-in table, the default cost model is used. You can extend the cost table or set explicit budget limits in USD.

Next Steps