promptflow-sdk
v0.1.0
Published
Version control and analytics for voice AI prompts
Maintainers
Readme
@promptflow/sdk
Version control and analytics for voice AI prompts
PromptFlow is like Git for AI prompts. Version control, instant rollbacks, A/B testing, and metrics tracking for voice AI agents built on Vapi, Retell, Bland AI, and custom voice stacks.
Installation
npm install @promptflow/sdk
# or
yarn add @promptflow/sdk
# or
pnpm add @promptflow/sdkQuick Start
import { PromptFlowClient } from '@promptflow/sdk';
// Initialize client
const client = new PromptFlowClient({
baseUrl: 'http://localhost:8000'
});
// Get production prompt
const promptContent = await client.getProductionPrompt('customer-support');
// Use with your voice AI platform
// Example with Vapi:
const assistant = await vapi.assistants.create({
model: {
provider: 'openai',
model: 'gpt-4',
messages: [
{ role: 'system', content: promptContent }
]
}
});
// Track conversation metrics
await client.trackConversation(
'customer-support',
true, // success
12, // turns
180, // duration in seconds
{ userId: 'user_123' }
);Features
- ✅ Version Control: Every prompt change creates an immutable version
- ✅ Instant Rollback: Revert to any previous version in seconds
- ✅ Analytics: Track success rates, turns, and duration per version
- ✅ Platform Integrations: Built-in helpers for Vapi, Retell, and Bland AI
- ✅ TypeScript: Full type definitions included
- ✅ Simple API: Clean, intuitive interface
Core Methods
Prompt Management
// List all prompts
const prompts = await client.listPrompts();
// Get prompt details
const prompt = await client.getPrompt('customer-support');
// Create new prompt
await client.createPrompt(
'sales-agent',
'You are a helpful sales agent',
'Initial version'
);
// Update prompt (creates new version)
await client.updatePrompt(
'sales-agent',
'You are an EXCELLENT sales agent',
'Made greeting more enthusiastic'
);Version Control
// Deploy specific version to production
await client.deployVersion('sales-agent', 2);
// Rollback to previous version
await client.deployVersion('sales-agent', 1);
// Get specific version
const version = await client.getVersion('sales-agent', 2);Analytics
// Track conversation
await client.trackConversation(
'sales-agent',
true, // success
8, // turns
145, // duration
{ userId: 'user_123', platform: 'vapi' }
);
// Get metrics
const metrics = await client.getMetrics('sales-agent');
console.log(`Success rate: ${metrics.success_rate}%`);
console.log(`Avg turns: ${metrics.avg_turns}`);
console.log(`Avg duration: ${metrics.avg_duration_seconds}s`);
// Get metrics for specific version
const metricsV2 = await client.getMetrics('sales-agent', 2);Platform Integrations
Vapi
const config = await client.getVapiConfig('sales-agent');
const assistant = await vapi.assistants.create({
model: {
messages: [{ role: 'system', content: config.content }]
}
});Retell AI
const config = await client.getRetellConfig('sales-agent');
const agent = await retell.agent.create({
agent_name: 'Sales Agent',
initial_prompt: config.initial_prompt
});Bland AI
const promptContent = await client.getBlandConfig('sales-agent');
const call = await bland.calls.create({
prompt: promptContent,
phone_number: '+1234567890'
});TypeScript Support
Full TypeScript definitions included:
import {
PromptFlowClient,
Prompt,
PromptVersion,
Metrics
} from '@promptflow/sdk';
const client = new PromptFlowClient({ baseUrl: 'http://localhost:8000' });
const prompt: Prompt = await client.getPrompt('sales-agent');
const metrics: Metrics = await client.getMetrics('sales-agent');Error Handling
try {
const prompt = await client.getPrompt('non-existent');
} catch (error) {
if (error.response?.status === 404) {
console.error('Prompt not found');
}
}Documentation
Visit http://localhost:3000/docs for complete documentation.
Requirements
- Node.js 16+
- PromptFlow backend instance running
License
MIT License
