§.Public API & SDK

TypeScript SDK

Install, configure, and use the official TypeScript SDK for the public REST API.

Updated 2026-04-13

Install

npm install @promptassay/sdk
# or
pnpm add @promptassay/sdk
# or
yarn add @promptassay/sdk

Configure

import { PromptAssay } from "@promptassay/sdk";

const pa = new PromptAssay({
  apiKey: "pa_live_your_api_key_here",
  // baseUrl is optional; defaults to https://promptassay.ai
});

Fetch a prompt at runtime

// Get the resolved content of a production prompt
const { data } = await pa.prompts.getResolved("prompt_abc123");
const systemPrompt = data.content;

// Pass to your LLM provider directly
const response = await anthropic.messages.create({
  model: "claude-sonnet-4-6",
  system: systemPrompt,
  messages: [{ role: "user", content: userInput }],
});

List and paginate

const firstPage = await pa.prompts.list({
  page: 1,
  per_page: 50,
  tag: "production",
});

console.log(firstPage.data.length, "prompts on page 1");
console.log(firstPage.meta.total, "prompts in total");

Errors

import { PromptAssayError } from "@promptassay/sdk";

try {
  await pa.prompts.get("missing");
} catch (err) {
  if (err instanceof PromptAssayError) {
    console.log(err.code, err.status, err.message);
  }
}