ReferenceTypeScript SDK

Prompts

client.prompts manages tenant-owned named message templates. Variables are inferred from {{variable}} placeholders and supplied only when invoking the Prompt.

Overview

Create requires name and template; omitted userId and metadata default to tenant-level and {}. Updates require at least one of name, template, or metadata; Attribution is immutable. Lists are unpaginated and optionally filter exact userId.

Methods

create()

create(body: CreatePromptBody): Promise<PromptResponse>POST /v1/prompts.

list()

list(userId?: string): Promise<PromptsResponse>GET /v1/prompts. Omit for all or pass "" for tenant-level Prompts.

get()

get(promptId: string): Promise<PromptResponse>GET /v1/prompts/:promptId.

update()

update(promptId: string, body: UpdatePromptBody): Promise<PromptResponse>PATCH /v1/prompts/:promptId. Omitted fields stay unchanged; changing the template recomputes variables.

delete()

delete(promptId: string): Promise<void>DELETE /v1/prompts/:promptId.

Types

PromptResponse contains IDs, name, template, inferred variable names, Attribution, and timestamps. The literal Prompt or its invocation ID is not retained in a transcript; only rendered text enters it. See objects and schemas.

Errors

Invalid placeholders, missing variable values, or extra variable names are invalid_request; inaccessible Prompts are not_found. See errors.

Example

import { BlazingAgents } from "@blazing-agents/sdk";
const client = new BlazingAgents({ apiKey: process.env.BLAZING_AGENTS_API_KEY! });
const agentId = "ag_0123456789abcdef";

const prompt = await client.prompts.create({
  name: "Release note",
  template: "Write a release note for {{feature}}.",
});
await client.prompts.list(prompt.userId);
await client.prompts.get(prompt.id);
await client.prompts.update(prompt.id, { metadata: { purpose: "release" } });
const result = await client.completion({
  agentId,
  promptId: prompt.id,
  variables: { feature: "faster search" },
});
console.log(await result.text);
await client.prompts.delete(prompt.id);

On this page