Teleprompter SDK is a TypeScript/JavaScript client library that enables developers to work with prompt management APIs and infrastructure provided by the Teleprompter platform. The SDK offers utilities to interact with Teleprompter APIs either over HTTP or by fetching and rendering prompt templates stored directly in a Cloudflare KV namespace, making it suitable for backend as well as edge/serverless environments.
getPromptVersions(id) and target a prior version with rollbackPrompt(id, version).Teleprompter.UpdateMessage({ id, prompt, version }) and deletions with Teleprompter.DeleteMessage(id).Teleprompter.HandleUpdates(batch, env, ctx), which writes updates to the PROMPTS KV namespace or deletes keys.// Publish an update
const msg = Teleprompter.UpdateMessage({
id: 'welcome-email',
prompt: 'Welcome, {{name}}!',
version: 1731166505 // UNIX timestamp (UTC)
})
await queue.send(msg)
// Apply updates in a Worker queue consumer
export default {
async queue(batch, env, ctx) {
await Teleprompter.HandleUpdates(batch, env, ctx)
}
}
id and version. Evict or refresh when a newer version is written. The SDK does not add an extra in-memory cache.The library exposes two primary client types, targeting different use cases and environments:
The HTTP client is designed to interact with a Teleprompter REST API server. It provides methods to list, read, update, and version prompt templates managed by your service. The API is intended for situations where you have a remote prompt registry or require centralized management (for example, enterprise APIs or development/CI/CD environments).
The KV client wraps access to a Cloudflare KV namespace that stores prompt templates. It is focused on scenarios where you want fast, serverless environment interpolation and rendering. The client seamlessly integrates with Mustache to interpolate variables directly on the edge, returning the generated prompt text.
This dual-client approach gives you flexibility to manage, distribute, and consume LLM prompts in a way that matches your architecture and runtime needs.
bun add teleprompter-sdk
# or
npm install teleprompter-sdk
Full API documentation is available at https://britt.github.io/teleprompter-sdk/
Create an HTTP instance with either a base URL or a Fetcher binding. The client implements methods for listing, retrieving, updating, and managing prompt templates remotely.
import Teleprompter from 'teleprompter-sdk';
const client = new Teleprompter.HTTP('https://api.example.com');
// List all prompts
const prompts = await client.listPrompts();
// Retrieve a prompt's latest version
const prompt = await client.getPrompt('welcome-email');
// Update or create a prompt
await client.writePrompt({ id: 'welcome-email', prompt: 'Welcome, {{name}}!' });
// Roll back a prompt to a previous version
await client.rollbackPrompt('welcome-email', 1731166505); // UNIX timestamp (UTC)
If you're running in an environment like Cloudflare Workers, you can pass a custom Fetcher (usually a service binding or mock object) to abstract the request layer:
const client = new Teleprompter.HTTP(env.API);
The KV client allows you to fetch templates from a Cloudflare KV namespace and render them directly with runtime context using Mustache.
const kv = new Teleprompter.KV(env);
const output = await kv.render('welcome-email', { name: 'Ada' });
This looks up the welcome-email prompt template in the PROMPTS namespace and renders it with the supplied context, returning the final text. This is ideal for edge/serverless workloads.
bun run build – Compile TypeScript sourcebun test – Run unit testsbun test --coverage – Run tests with coverage reportbun run docs – Generate TypeDoc documentation to the docs/ folderContinuous integration automatically runs tests on every pull request.
This project uses Bun as its runtime and package manager.
Install dependencies:
bun install
Run tests:
bun test
Generate documentation:
bun run docs
Documentation is automatically published to GitHub Pages from the docs/ directory.
This project is licensed under the MIT License.