cost_guard_ai
v1.0.0
Published
Intelligent Prompt Compression and Security Middleware for LLMs / LLM을 위한 지능형 프롬프트 압축 및 보안 미들웨어
Maintainers
Readme
COST_GUARD_AI
Intelligent Prompt Compression & Security Middleware for LLMs
LLM을 위한 지능형 프롬프트 압축 및 보안 미들웨어
English Description
cost_guard_ai is a powerful guardian for developers and enterprises using LLM APIs (OpenAI, Anthropic, etc.). It sits between your application and the AI to optimize costs, ensure data privacy, and maintain high response quality.
Key Features
- Semantic Prompt Compression: Reduces token consumption by 20-30% while maintaining context.
- PII Masking: Automatically detects and masks sensitive information (emails, phone numbers, credit cards, etc.).
- Caching Layer: Instantly returns responses for identical or similar queries from a local/DB cache.
- Budget Management: Monitors API usage and prevents overspending with budget alerts and hard limits.
한국어 설명
cost_guard_ai는 LLM API(OpenAI, Anthropic 등)를 사용하는 개발자와 기업을 위한 강력한 가디언입니다. 애플리케이션과 AI 사이에서 비용을 최적화하고, 데이터 프라이버시를 보장하며, 높은 응답 품질을 유지합니다.
핵심 기능
- 지능형 프롬프트 압축 (Semantic Prompt Compression): 문맥을 유지하면서 토큰 사용량을 20~30% 절감합니다.
- 개인정보 마스킹 (PII Masking): 이메일, 전화번호, 신용카드 번호 등 민감 정보를 자동으로 탐지하여 마스킹 처리합니다.
- 캐싱 레이어 (Caching Layer): 동일하거나 유사한 질문에 대해 로컬/DB 캐시에서 즉시 응답을 반환합니다.
- 예산 관리 (Budget Management): API 사용량을 모니터링하고 설정된 예산을 초과하지 않도록 알림 및 차단 기능을 제공합니다.
Installation / 설치
npm install cost_guard_aiUsage / 사용법
import { AICostGuard } from 'cost_guard_ai';
import OpenAI from 'openai';
const guard = new AICostGuard({
maxTokenBudget: 10000, // Daily budget limit / 일일 예산 설정
maskPII: true, // Enable PII masking / 개인정보 마스킹 활성화
compress: true // Enable prompt compression / 프롬프트 압축 활성화
});
const openai = new OpenAI();
// Wrap the existing call / 기존 호출 방식에 가드를 입힘
const response = await guard.wrap(openai.chat.completions.create({
model: "gpt-4",
messages: [{ role: "user", content: "Check the balance for customer Hong Gil-dong (010-1234-5678)." }]
}));License / 라이선스
MIT License Copyright (c) 2008-2026 Rheehose (Rhee Creative)
