Skip to content

Interface: PromptsResource ​

Methods ​

invalidate() ​

ts
invalidate(): void;

Forgets the cached environment, so the next resolve fetches it again.

Returns ​

void


resolve() ​

ts
resolve(promptId, options?): Promise<PromptResolveResult>;

Resolves a prompt to ready-to-run text.

You get the version deployed in your key's environment — the key decides which environment, so deploying a version is what moves your callers. The whole environment is fetched once and kept in memory; every {{variable}} is filled in your process from vars, so later calls usually make no request and the values are never sent. A missing variable is an error rather than an empty string, and keys the prompt does not use are ignored.

The text is what the version's benchmark ran: a classic prompt with its values written in, a BRAID graph framed with its values beside it. Run it as the system message.

Parameters ​

promptId ​

string

The prompt's id — not its name. The page of any of its versions in the app shows it, with a copy button.

options? ​

PromptResolveOptions = {}

Variable values and an optional AbortSignal.

Returns ​

Promise<PromptResolveResult>

The ready-to-run prompt text, and which version produced it.

Throws ​

When a variable the prompt needs is missing or not a string, or the template holds a malformed placeholder.

Throws ​

401 when the key is rejected, 404 when nothing is deployed for that prompt id in the key's environment.

Throws ​

TimeoutError when the API does not answer within timeoutMs and there is no cached copy to serve.

Example ​

ts
const { prompt, version } = await client.prompts.resolve(
  INTENT_CLASSIFIER_ID,
  { vars: { utterance: "cancel my plan" } },
);

Released under the MIT licence.