Skip to content

prompts.resolve()

ts
client.prompts.resolve(
  promptIdSpec: string,
  options?: {
    vars?: Record<string, string>;
    signal?: AbortSignal;
  },
): Promise<{
  prompt: string;
  promptVersionId: string;
  version: string;
}>

Resolves a prompt's production version and substitutes its variables, server side. It performs no inference.

Parameters

NameTypeDescription
promptIdSpecstringThe prompt id, optionally pinned to a version with @vN.
options.varsRecord<string, string>Values for the {{variables}} in the prompt body.
options.signalAbortSignalCancels the in-flight request.

Returns

FieldTypeDescription
promptstringThe substituted, ready-to-run prompt text. No {{...}} remain.
promptVersionIdstringId of the exact version that was resolved — worth logging next to the model's output.
versionstringThe resolved label, e.g. "v7".

Version pinning

ts
// Always whatever is promoted to production right now.
await client.prompts.resolve("intent-classifier", { vars });

// Pinned. Promoting a new version does not move this caller.
await client.prompts.resolve("intent-classifier@v7", { vars });

Unpinned callers follow production, which is the point: one promotion changes every caller that did not ask to stay put. A prompt with no production version and no pin fails with 404.

Calls in parallel

Each call is one HTTP request and holds no client-side state, so batches are just Promise.all:

ts
const resolved = await Promise.all(
  customers.map((c) =>
    client.prompts.resolve("welcome-email", {
      vars: { name: c.name, plan: c.plan },
    }),
  ),
);

Cancellation

ts
const controller = new AbortController();
const promise = client.prompts.resolve("slow-prompt", {
  vars: {},
  signal: controller.signal,
});
setTimeout(() => controller.abort(), 5_000);

Released under the MIT licence.