TypeScript SDK

Prompts

Save reusable prompt templates with variables and manage them with the TypeScript SDK.

client.prompts saves prompt templates you reuse across turns. Write {{variable}} placeholders in the template, then run it by passing its promptId and variables to chat(), completion(), or object(). To learn when a saved prompt helps, read Prompts.

const prompt = await client.prompts.create({
  name: "Release note",
  template: "Write a release note for {{feature}}.",
});

const result = await client.completion({
  agentId,
  promptId: prompt.id,
  variables: { feature: "faster search" },
});
console.log(await result.text);

Every method takes one input object and accepts an optional abortSignal.

Templates

  • Variable names match [A-Za-z_][A-Za-z0-9_]*. A template has up to 10 different variables and 10,240 characters.
  • Blazing Agents reads the variables from the template and returns them in variables.
  • When you run a prompt, pass every variable and no others, or the turn fails with prompt_variable_missing or prompt_variable_unknown.
  • Only the filled-in text is saved in the session, so editing or deleting a prompt later does not change past conversations.

Available operations

MethodDescriptionReturns
create()Save a promptPromptResponse
list()List promptsPromptsResponse
get()Read one promptPromptResponse
update()Change a promptPromptResponse
delete()Delete a promptvoid

Methods

create()

Saves a prompt template.

Signature: create(input: CreatePromptBody & ResourceRequestOptions): Promise<PromptResponse>

const prompt = await client.prompts.create({
  name: "Release note",
  template: "Write a release note for {{feature}} aimed at {{audience}}.",
  agentId,
});
FieldTypeRequiredDefaultDescription
namestringyesnone1 to 80 characters, unique in your tenant
templatestringyesnoneThe template text
agentIdstring | nullnonullAgent to link it to, for your own grouping
userIdstringno""The end user it belongs to; cannot change later
metadataRecord<string, unknown>no{}Your labels

Deleting the linked agent also deletes the prompt. Your tenant can hold up to 100 prompts. Returns PromptResponse. Errors: validation_failed, prompt_name_conflict, prompt_limit_reached, and not_found when the agent does not exist.

list()

Lists your prompts, most recently updated first.

Signature: list(input?: { userId?: string; agentId?: string } & ResourceRequestOptions): Promise<PromptsResponse>

const { prompts } = await client.prompts.list({ agentId });
ParameterTypeRequiredDescription
userIdstringnoOnly this end user's prompts; "" for tenant-level ones
agentIdstringnoOnly prompts linked to this agent

The result is not paginated. Returns { prompts: PromptResponse[] }.

get()

Reads one prompt.

Signature: get(input: { promptId: string } & ResourceRequestOptions): Promise<PromptResponse>

const prompt = await client.prompts.get({ promptId });
console.log(prompt.variables);

Returns PromptResponse. Errors: validation_failed, not_found.

update()

Changes a prompt's name, template, agent link, or metadata.

Signature: update(input: UpdatePromptBody & { promptId: string } & ResourceRequestOptions): Promise<PromptResponse>

const prompt = await client.prompts.update({
  promptId,
  template: "Summarize {{feature}} for {{audience}}.",
});

Takes promptId plus any of name, template, agentId, and metadata, with at least one. Fields you leave out stay as they are; metadata replaces all metadata, and agentId: null removes the link. userId cannot change. The next turn that uses the prompt gets the new template.

Returns PromptResponse. Errors: validation_failed, prompt_name_conflict, not_found.

delete()

Deletes a prompt for good.

Signature: delete(input: { promptId: string } & ResourceRequestOptions): Promise<void>

await client.prompts.delete({ promptId });

Errors: validation_failed, not_found.

Response types

PromptResponse

FieldTypeDescription
idstringPrompt ID (prompt_…)
tenantIdstringYour tenant ID
agentIdstring | nullLinked agent, or null
namestringPrompt name
templatestringThe template text
variablesstring[]Variable names, in the order they first appear
userIdstringThe end user it belongs to, or ""
metadataRecord<string, unknown>Your labels
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp

PromptsResponse is { prompts: PromptResponse[] }.

Errors

Failures throw BlazingAgentsError. The prompt codes:

CodeMeaning
prompt_name_conflictAnother prompt has this name
prompt_limit_reachedYour tenant already has 100 prompts
prompt_variable_missingA turn left out one of the prompt's variables
prompt_variable_unknownA turn passed a variable the template does not use

Next

On this page