Batch Render
Render up to 50 prompts in a single request
Batch Render
Render up to 50 prompts in a single request. Each item specifies a promptId, optional version, and variables. This is useful for pre-rendering multiple prompts at once -- for example, generating personalized messages for a batch of users.
Endpoint
http
POST /api/sdk/render/batchRequest Body
json
{
"items": [
{ "promptId": 1, "version": "published", "variables": { "name": "Alice" } },
{ "promptId": 2, "variables": { "name": "Bob" } },
{ "promptId": 1, "version": 3, "variables": { "name": "Charlie" } }
]
}Response
json
{
"results": {
"1": { "content": "Hello Alice!", "versionNo": 5, "error": null },
"2": { "content": "Hello Bob!", "versionNo": 2, "error": null }
},
"successCount": 3,
"errorCount": 0
}SDK Usage
const batch = await es.batchRender([
{ promptId: 1, variables: { name: "Alice" } },
{ promptId: 2, variables: { name: "Bob" } },
])
console.log(batch.successCount) // 2
console.log(batch.results["1"].content) // "Hello Alice!"Version Pinning
Each item in the batch can optionally specify a version field. This can be a string like "published" or "staging", or a specific version number. If omitted, the latest version is used.
Limits
- Maximum 50 items per batch request
- The same prompt ID can appear multiple times with different variables or versions
- Results are keyed by prompt ID -- if the same ID appears multiple times, the last result wins