Official JavaScript/TypeScript SDK for Raison - prompt management for AI applications.
npm install raisonimport { Raison } from 'raison'
const raison = new Raison({
apiKey: 'rsn_dev_your_api_key',
})
// Render a prompt with variables
const text = await raison.render('prompt-id', {
company: 'Acme Inc',
userName: 'Alice',
})
// Find prompts by agent
const prompts = await raison.find({ agentId: 'agent-id' })
// Get a specific prompt
const prompt = await raison.findOne({ agentId: 'agent-id', name: 'System Prompt' })const raison = new Raison({
apiKey: string, // Required. Starts with 'rsn_'
baseUrl?: string, // Optional. Defaults to Raison.BASE_URL
})Render a prompt by ID. Returns empty string if not found.
const text = await raison.render('prompt-id', { userName: 'Alice' })
// Without variables returns raw template
const raw = await raison.render('prompt-id')Search prompts by any field.
const prompts = await raison.find({ agentId: 'agent-id' })Get a single prompt.
const prompt = await raison.findOne({ agentId: 'agent-id', name: 'System Prompt' })
if (prompt) {
const text = await raison.render(prompt.id, { userName: 'Alice' })
}Prompt fields: id, name, agentId, version, content
Close the WebSocket connection.
raison.disconnect()Register a custom Handlebars helper for use in prompt templates.
// Register helpers before rendering
Raison.registerHelper('uppercase', (str: string) => str.toUpperCase())
Raison.registerHelper('json', (value: unknown) => JSON.stringify(value, null, 2))
// Now usable in templates: {{uppercase userName}}, {{json data}}
const text = await raison.render('prompt-id', { userName: 'Alice', data: { foo: 1 } })Prompts use Handlebars:
MIT