Dry-run render a Prompt template
POST /v1/prompt-templates/{prompt_template_id}/render
| Property | Value |
|---|---|
| Operation | render_prompt_template |
| Group | Prompt templates |
| Scope | prompts:read |
| Route class | read |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Not audited: A dry run: it changes no state and reads no Call content, so it writes no Audit event (ADR 0012, prompt-manager.md section 7). |
| Released in | 1.55.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Renders the draft, or a version, for one variant with the synthetic variables, slots, state, Call fields, constants and retrieval outcomes of the body, and answers its section with a token estimate, the stable prefix, the names of missing values and the lint findings (1.55.0). A body that does not parse is 422 validation_failed with template_invalid; a value of the wrong type is variable_type. It writes nothing: no Call, Audit or Usage event.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the prompts:read scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/prompt-templates/ptpl_.../render" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'const response = await fetch(`${process.env.VOCAL_API}/v1/prompt-templates/ptpl_.../render`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/prompt-templates/ptpl_.../render",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
prompt_template_id | path | PromptTemplateId | yes | The id of a Prompt template: ptpl_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: PromptTemplateRenderRequest.
| Field | Type | Required | Description |
|---|---|---|---|
call | PromptRenderCallInput | no | |
constants | map of PromptConstantValue | no | Organization constants for this render; those of the Organization layer the render resolves when omitted. display_name is the Organization name. |
retrieval | map of boolean | no | Whether each Knowledge binding returned passages for this request, by handle: true renders the first branch of its retrieval slot, false or absent the second. |
slots | map of PromptSlotValue | no | Synthetic slot values; an unset slot renders empty or its default(). |
state | string | no | The active state, the state root. |
time_now | RequestTimestamp | no | The time.now root; the request instant when omitted. |
variables | map of VariableValue | no | Synthetic values of the declared variables. A value of an undeclared name is variable_unknown, of the wrong type variable_type; an optional variable without a value renders empty and is named in missing_values. |
variant | PromptVariantKey | no | The variant to render; default when omitted, and default for a key the template lacks. |
version | integer | no | The version to render; the draft when omitted. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | PromptRenderResult | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is PromptRenderResult.
| Field | Type | Required | Description |
|---|---|---|---|
lint | array of PromptLintFinding | yes | The lint findings of what was rendered: the stored findings of a version, those of the draft, and for an Agent version the cross-checks of its publish. |
missing_values | array of PromptValuePath | yes | The paths that rendered empty for want of a value, such as variables.clinician_name (missing_value); names only, never a value. |
object | "prompt_render" | yes | |
sections | array of PromptRenderSection | yes | In composition order. |
stable_prefix_tokens | integer | yes | The tokens before the first per-Call or per-Turn value, which a Provider that caches prompts may reuse between requests (prompt-manager.md section 4). |
total_tokens | integer | yes | |
variant | PromptVariantKey | yes |