Quick Start¶
Get up and running with Promptel in 5 minutes.
Prerequisites¶
- Node.js 18+ installed
- API key from OpenAI, Anthropic, or Groq
Step 1: Create a Project¶
Step 2: Set Your API Key¶
Step 3: Write Your First Prompt¶
Create app.js:
const { executePrompt } = require('promptel');
async function main() {
const result = await executePrompt(`
prompt Summarizer {
params {
text: string
}
body {
text\`Summarize the following text in 2-3 sentences:
\${params.text}\`
}
constraints {
maxTokens: 150
temperature: 0.7
}
}
`, {
text: `Artificial intelligence has transformed how we interact with technology.
From voice assistants to recommendation systems, AI is now embedded in our
daily lives. Machine learning algorithms analyze vast amounts of data to
make predictions and automate decisions that previously required human judgment.`
});
console.log(result);
}
main();
Step 4: Run It¶
You'll see a concise summary generated by the LLM.
Using YAML Format¶
Prefer YAML? Create summarizer.yml:
name: Summarizer
params:
text:
type: string
required: true
body:
text: |
Summarize the following text in 2-3 sentences:
${params.text}
constraints:
maxTokens: 150
temperature: 0.7
Execute it:
const fs = require('fs');
const { executePrompt } = require('promptel');
const promptYaml = fs.readFileSync('summarizer.yml', 'utf-8');
const result = await executePrompt(promptYaml, {
text: "Your text here..."
});
Using the CLI¶
Execute prompts directly from the command line:
# Create a prompt file
echo 'prompt Hello { body { text`Say hello to the user` } }' > hello.prompt
# Execute it
promptel -f hello.prompt -p openai -k $PROMPTEL_API_KEY
Switching Providers¶
Use any supported provider:
// OpenAI (default)
const result = await executePrompt(prompt, params, {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY
});
// Anthropic Claude
const result = await executePrompt(prompt, params, {
provider: 'claude',
apiKey: process.env.ANTHROPIC_API_KEY
});
// Groq
const result = await executePrompt(prompt, params, {
provider: 'groq',
apiKey: process.env.GROQ_API_KEY
});
What's Next?¶
- Your First Prompt - Deep dive into prompt structure
- Techniques - Add Chain-of-Thought and more
- Harmony Protocol - Multi-channel responses