JSPM

@fabrk/ai

0.3.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q38568F
  • License MIT

AI development toolkit with cost tracking, validation, and testing

Package Exports

  • @fabrk/ai

Readme

@fabrk/ai

AI development toolkit with cost tracking, validation, and testing.

Installation

npm install @fabrk/ai
# Plus your AI provider:
npm install openai  # or @anthropic-ai/sdk or @ai-sdk/openai

Usage

import { trackCost, validateCost, AIProvider } from '@fabrk/ai'

const response = await trackCost(
  'chat-feature',
  async () => {
    return await openai.chat.completions.create({
      model: 'gpt-4',
      messages: [{ role: 'user', content: 'Hello!' }]
    })
  }
)

// With validation
const safe = await validateCost(() => expensiveAICall(), {
  maxCost: 0.50,
  dailyBudget: 10.00
})

Features

  • Cost Tracking - Automatic cost calculation for OpenAI, Anthropic, Google
  • Budget Management - Daily/monthly budget enforcement
  • Validation - Pre-flight cost checks
  • Multi-provider - Works with all major AI providers
  • Type-safe - Full TypeScript support

Supported Providers

  • OpenAI (GPT-4, GPT-3.5)
  • Anthropic (Claude)
  • Google (Gemini)
  • Ollama (local models)

Documentation

View full documentation

License

MIT