// sdk & install
Drop one file in.
Optimize every AI call.
The PromptForge SDK is two TypeScript files. No build step, no lock-in. Auto-routes to the cheapest model, tracks every dollar, and stops runaway spend.
Auto model routing
Every call automatically picks the cheapest model that meets your quality floor. No code changes needed.
Per-call cost tracking
Exact cost logged for every request. Aggregated by feature, model, and provider.
Budget alerts
Set session, daily, or monthly limits. Get notified — or stop execution — before you overspend.
Dashboard sync
All spend automatically appears in your PromptForge dashboard. One view across all projects.
// one-line install
Or install in any project with one command
Run this from your project root. Downloads the SDK, config, CLAUDE.md, and installs peer deps.
curl -fsSL https://promptforge-ebon.vercel.app/sdk/install.sh | bash
// quick start
Or step-by-step in 4 steps
npm install ai @ai-sdk/anthropic @ai-sdk/openai @ai-sdk/google
# Download from your dashboard or copy from below # promptforge-sdk.ts # promptforge.config.ts
ANTHROPIC_API_KEY=sk-ant-... OPENAI_API_KEY=sk-... GOOGLE_GENERATIVE_AI_API_KEY=AI... PROMPTFORGE_API_KEY=your-key # optional, enables dashboard sync
import pf from "./promptforge-sdk"
// Before:
const { text } = await generateText({ model: anthropic("claude-3-5-haiku"), prompt })
// After:
const result = await pf.text(prompt, { feature: "my-feature" })
console.log(result.text, result.costUsd)// usage
Full example with budget monitoring
import pf from "./promptforge-sdk"
// Start background cost monitor — logs every 30s
const stopMonitor = pf.startMonitor({ intervalMs: 30_000, reportTo: "console" })
async function runAgent(task: string) {
// Cheap model for planning
const plan = await pf.text(`Break this into 5 steps: ${task}`, {
feature: "planning",
prefer: "cheapest",
})
// Better model only where it matters
const result = await pf.text(`Execute: ${plan.text}`, {
feature: "execution",
prefer: "balanced",
minQuality: 85,
})
console.log(`Done — spent $${result.sessionSpend.toFixed(6)} total`)
return result.text
}
await runAgent("Analyze Q1 sales data and write a summary report")
stopMonitor()
pf.printReport()
// ╔══════════════════════════════════════╗
// ║ PromptForge Spend Report ║
// ╚══════════════════════════════════════╝
// Total spend : $0.000312
// API calls : 2
// By model:
// gemini-2.0-flash $0.000041 (1 calls)
// claude-3-5-haiku-20241022 $0.000271 (1 calls)
// By feature:
// planning $0.000041 (1 calls)
// execution $0.000271 (1 calls)// downloads
Download the files
promptforge-sdk.ts
Core SDK — drop into your project root
promptforge.config.ts
Config template — edit budget & routing
CLAUDE.md
Claude Code rules — tells AI to use the SDK
Sign in for a personalized config with your API key and project ID pre-filled.
// claude code
Works with Claude Code
Drop CLAUDE.md into your project root. Claude Code will automatically follow cost-optimization rules on every AI call it writes.
# PromptForge Cost Rules
- ALWAYS use pf.text() instead of calling provider SDKs directly
- ALWAYS pass a feature label: pf.text(prompt, { feature: "name" })
- Use prefer: "cheapest" for drafts, summaries, and classification
- Use prefer: "best" only for final user-facing outputs
- Call pf.printReport() at the end of every agent sessionReady to stop overpaying?
Sign up free — get your API key, project ID, and a pre-filled config in 60 seconds.
Get started free →