NPM Package

Use our npm package for easy integration with Node.js applications. The package provides a simple client for accessing your structured prompts.

Installation

Install the SuperPrompts package using npm or yarn:

npm install superprompts
yarn add superprompts

Basic Usage

Import the package and create a client with your API key:

import { createPromptClient } from 'superprompts';

const client = createPromptClient('<API_KEY>');

// Get a prompt (all sections combined)
const systemPromptContent = await client.prompt('<PROMPT_ID>');

console.log(systemPromptContent);
// Returns all 7 sections combined in optimal order

API Reference

createPromptClient(apiKey: string)

Creates a new SuperPrompts client instance.

Parameters:
  • apiKey (string) - Your project API key
Returns:

A client instance with methods to access your prompts

client.prompt(promptId: string)

Retrieves a prompt by its ID. Returns the combined content of all 7 sections, ready to send to any AI provider.

Parameters:
  • promptId (string) - The ID of the prompt to retrieve
Returns:

Promise<string> - The combined prompt content

Examples

Express.js Integration

import express from 'express';
import { createPromptClient } from 'superprompts';

const app = express();
const client = createPromptClient(process.env.SUPERPROMPTS_API_KEY);

app.get('/chat', async (req, res) => {
  try {
    // Get structured prompt (all sections combined)
    const systemPrompt = await client.prompt('customer-support-bot');
    // Use systemPrompt with your AI model
    res.json({ prompt: systemPrompt });
  } catch (error) {
    res.status(500).json({ error: 'Failed to fetch prompt' });
  }
});

app.listen(3000);

Next.js API Route

import { createPromptClient } from 'superprompts';
import { NextResponse } from 'next/server';

const client = createPromptClient(process.env.SUPERPROMPTS_API_KEY!);

export async function GET() {
  try {
    const systemPrompt = await client.prompt('my-prompt');
    return NextResponse.json({ prompt: systemPrompt });
  } catch (error) {
    return NextResponse.json(
      { error: 'Failed to fetch prompt' },
      { status: 500 }
    );
  }
}

With OpenAI

import { createPromptClient } from 'superprompts';
import OpenAI from 'openai';

const promptClient = createPromptClient(process.env.SUPERPROMPTS_API_KEY);
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

async function chat(userMessage: string) {
  // Get structured prompt
  const systemPrompt = await promptClient.prompt('assistant');
  
  const completion = await openai.chat.completions.create({
    model: 'gpt-4',
    messages: [
      { role: 'system', content: systemPrompt },
      { role: 'user', content: userMessage }
    ]
  });
  
  return completion.choices[0].message.content;
}

Next Steps