Declarative prompt engineering. Write once, run anywhere.
Promptel is a declarative framework for building production-grade LLM prompts. Define your prompts in a clean DSL or YAML, use built-in techniques like Chain-of-Thought, and deploy across OpenAI, Anthropic, or Groq without changing code.
const { executePrompt } = require('promptel');
const result = await executePrompt(`
prompt CodeReviewer {
params { code: string }
body {
text\`Review this code for bugs and security issues:
\${params.code}\`
}
technique {
chainOfThought {
step("Security") { text\`Check for vulnerabilities\` }
step("Logic") { text\`Identify bugs\` }
step("Quality") { text\`Suggest improvements\` }
}
}
}
`, { code: userCode });npm install promptel1. Set your API key:
export PROMPTEL_API_KEY=sk-your-key2. Create a prompt:
// app.js
const { executePrompt } = require('promptel');
async function main() {
const result = await executePrompt(`
prompt Summarizer {
params { text: string }
body { text\`Summarize in 2 sentences: \${params.text}\` }
constraints { maxTokens: 100 }
}
`, { text: "Your long article here..." });
console.log(result);
}
main();3. Run it:
node app.js| Feature | Description |
|---|---|
| Dual Format | Write prompts in .prompt DSL or YAML |
| Multi-Provider | OpenAI, Anthropic, Groq with consistent API |
| Techniques | Built-in Chain-of-Thought, Few-Shot, Tree-of-Thoughts |
| Harmony Protocol | Native multi-channel responses (OpenAI) |
| Type-Safe Params | Typed parameters with defaults and validation |
| CLI Included | Execute and convert prompts from terminal |
Promptel supports two equivalent formats:
| .prompt (DSL) | YAML |
|---|---|
prompt Greeter {
params {
name: string
lang?: string = "en"
}
body {
text`Hello ${params.name}!`
}
} |
name: Greeter
params:
name:
type: string
required: true
lang:
type: string
default: "en"
body:
text: "Hello ${params.name}!" |
Convert between them:
promptel --convert yaml -f prompt.prompt -o prompt.ymlSwitch providers without changing prompts:
// OpenAI (default)
await executePrompt(prompt, params, { provider: 'openai' });
// Anthropic Claude
await executePrompt(prompt, params, { provider: 'claude' });
// Groq
await executePrompt(prompt, params, { provider: 'groq' });Built-in prompting techniques:
prompt Analyzer {
technique {
// Step-by-step reasoning
chainOfThought {
step("Understand") { text`Parse the input` }
step("Analyze") { text`Find patterns` }
step("Conclude") { text`Form conclusions` }
}
}
}Available techniques:
chainOfThought- Step-by-step reasoningfewShot- Learning from exampleszeroShot- Direct instructiontreeOfThoughts- Multiple solution pathsreAct- Reasoning + ActionsselfConsistency- Multi-sample consensus
Multi-channel responses for advanced reasoning:
prompt HarmonyExample {
harmony {
reasoning: "high"
channels: ["final", "analysis", "commentary"]
}
body { text`Solve: ${params.problem}` }
}const result = await executePrompt(harmonyPrompt, { problem: "..." });
console.log(result.channels.final); // Clean answer
console.log(result.channels.analysis); // Reasoning steps
console.log(result.channels.commentary); // Additional context# Execute prompt
promptel -f prompt.prompt -p openai -k $KEY --params '{"x":"value"}'
# Convert formats
promptel --convert yaml -f prompt.prompt
# Output to file
promptel -f prompt.yml -p claude -k $KEY -o result.jsonconst {
parsePrompt, // Parse .prompt or YAML to AST
executePrompt, // Execute prompt end-to-end
FormatConverter, // Convert between formats
PromptelExecutor, // Low-level executor
createProvider, // Create provider instance
} = require('promptel');
// Parse without executing
const ast = parsePrompt(promptContent);
// Execute with options
const result = await executePrompt(content, params, {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY
});
// Convert formats programmatically
const converter = new FormatConverter();
const yaml = converter.promptToYaml(promptContent);promptel/
├── src/
│ ├── index.js # Main exports
│ ├── parser.js # .prompt parser (Chevrotain)
│ ├── yaml-parser.js # YAML parser
│ ├── executor.js # Execution engine
│ ├── provider.js # LLM providers
│ ├── format-converter.js
│ └── cli.js
├── tests/
├── examples/
└── documentation/ # MkDocs site
git clone https://github.com/skelf-research/promptel.git
cd promptel
npm install
# Run tests
npm test
# Run linter
npm run lint
# Run integration tests
npm run test:integrationFull documentation available at promptel.dev or in the documentation/ folder:
- Node.js 18+
- API key from OpenAI, Anthropic, or Groq
Contributions welcome! Please read our contributing guidelines and submit PRs.
npm run lint # Check code style
npm test # Run tests
npm run validate # Full validationMIT License - see LICENSE for details.
Built for developers who ship AI to production.