@modelcost/sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -618,22 +618,7 @@ var BudgetManager = class {
618
618
  };
619
619
 
620
620
  // src/tracking.ts
621
- function _loadBundledPricing() {
622
- return /* @__PURE__ */ new Map([
623
- ["gpt-4", { provider: "openai", model: "gpt-4", inputCostPer1k: 0.03, outputCostPer1k: 0.06 }],
624
- ["gpt-4-turbo", { provider: "openai", model: "gpt-4-turbo", inputCostPer1k: 0.01, outputCostPer1k: 0.03 }],
625
- ["gpt-4o", { provider: "openai", model: "gpt-4o", inputCostPer1k: 5e-3, outputCostPer1k: 0.015 }],
626
- ["gpt-4o-mini", { provider: "openai", model: "gpt-4o-mini", inputCostPer1k: 15e-5, outputCostPer1k: 6e-4 }],
627
- ["gpt-3.5-turbo", { provider: "openai", model: "gpt-3.5-turbo", inputCostPer1k: 15e-4, outputCostPer1k: 2e-3 }],
628
- ["claude-opus-4", { provider: "anthropic", model: "claude-opus-4", inputCostPer1k: 0.015, outputCostPer1k: 0.075 }],
629
- ["claude-sonnet-4", { provider: "anthropic", model: "claude-sonnet-4", inputCostPer1k: 3e-3, outputCostPer1k: 0.015 }],
630
- ["claude-haiku-4", { provider: "anthropic", model: "claude-haiku-4", inputCostPer1k: 25e-5, outputCostPer1k: 125e-5 }],
631
- ["gemini-1.5-pro", { provider: "google", model: "gemini-1.5-pro", inputCostPer1k: 125e-5, outputCostPer1k: 5e-3 }],
632
- ["gemini-1.5-flash", { provider: "google", model: "gemini-1.5-flash", inputCostPer1k: 75e-6, outputCostPer1k: 3e-4 }],
633
- ["gemini-2.0-flash", { provider: "google", model: "gemini-2.0-flash", inputCostPer1k: 1e-4, outputCostPer1k: 4e-4 }]
634
- ]);
635
- }
636
- var _modelPricing = _loadBundledPricing();
621
+ var _modelPricing = /* @__PURE__ */ new Map();
637
622
  var MODEL_PRICING = _modelPricing;
638
623
  async function syncPricingFromApi(baseUrl, apiKey) {
639
624
  try {
@@ -1838,7 +1823,7 @@ var ModelCost = class _ModelCost {
1838
1823
  * Initialize the ModelCost SDK. Must be called before any other method.
1839
1824
  * Subsequent calls will re-initialize (shutting down the previous instance).
1840
1825
  */
1841
- static init(options) {
1826
+ static async init(options) {
1842
1827
  if (_ModelCost._instance) {
1843
1828
  _ModelCost._instance.costTracker.stopAutoFlush();
1844
1829
  _ModelCost._instance.costTracker.stopPricingSync();
@@ -1846,6 +1831,11 @@ var ModelCost = class _ModelCost {
1846
1831
  }
1847
1832
  const config = new ModelCostConfig(options);
1848
1833
  const client = new ModelCostClient(config);
1834
+ try {
1835
+ await syncPricingFromApi(config.baseUrl, config.apiKey);
1836
+ } catch {
1837
+ console.warn("[ModelCost] Failed to sync pricing on init; cost estimates unavailable until next sync");
1838
+ }
1849
1839
  const budgetManager = new BudgetManager(config.syncIntervalMs);
1850
1840
  const costTracker = new CostTracker(config.flushBatchSize);
1851
1841
  const piiScanner = new PiiScanner();