@stackmemoryai/stackmemory
Version:
Lossless, project-scoped memory for AI coding tools. Durable context across sessions with 56 MCP tools, FTS5 search, conductor orchestrator, loop/watch monitoring, snapshot capture, pre-flight overlap checks, Claude/Codex/OpenCode wrappers, Linear sync, a
64 lines (63 loc) • 1.71 kB
JavaScript
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
const MODEL_PRICING = {
// Anthropic (direct API)
"anthropic/claude-sonnet-4-5-20250929": {
inputPer1M: 3,
outputPer1M: 15,
source: "anthropic.com"
},
"anthropic/claude-sonnet-4-20250514": {
inputPer1M: 3,
outputPer1M: 15,
source: "anthropic.com"
},
"anthropic/claude-haiku-4-5-20251001": {
inputPer1M: 0.8,
outputPer1M: 4,
source: "anthropic.com"
},
// OpenAI (direct API)
"openai/gpt-4o": {
inputPer1M: 2.5,
outputPer1M: 10,
source: "openai.com"
},
// OpenRouter (aggregated)
"openrouter/meta-llama/llama-4-scout": {
inputPer1M: 0.08,
outputPer1M: 0.3,
source: "openrouter.ai/api/v1/models"
},
// Cerebras (free tier / inference)
"cerebras/llama-4-scout-17b-16e-instruct": {
inputPer1M: 0.1,
outputPer1M: 0.1,
source: "cerebras.ai"
},
// DeepInfra
"deepinfra/THUDM/glm-4-9b-chat": {
inputPer1M: 0.065,
outputPer1M: 0.065,
source: "deepinfra.com"
}
};
function calculateCost(provider, model, inputTokens, outputTokens) {
const key = `${provider}/${model}`;
const pricing = MODEL_PRICING[key];
if (!pricing) return null;
const inputCost = inputTokens / 1e6 * pricing.inputPer1M;
const outputCost = outputTokens / 1e6 * pricing.outputPer1M;
return { inputCost, outputCost, totalCost: inputCost + outputCost };
}
function formatCost(usd) {
if (usd < 0.01) return `$${usd.toFixed(6)}`;
return `$${usd.toFixed(4)}`;
}
export {
MODEL_PRICING,
calculateCost,
formatCost
};