Quickstart
Your application calls ReadPrompt by prompt name or ID. ReadPrompt validates variables, selects an eligible model-ready target, and returns output that matches your published schema.
- 01Create a project and prompt
Define variables and an output contract, then publish a version with at least one enabled
READYtarget. - 02Create an execution API key
Use a project-scoped key with the
executescope and store it in your server environment. - 03Install the SDK or call the API
Use the official server-side SDK, or send a JSON
variablesobject to the stable Executor endpoint. - 04Use validated data
Read the prompt-specific
dataobject and logrequest_idfor troubleshooting.
How execution works
ReadPrompt separates the application contract from the model decision. Your backend calls one prompt identity; ReadPrompt selects an eligible target and returns only schema-valid data.
Why prompt names
A prompt name is a stable, readable application identifier such as customer-support-reply. Your application calls that name, while ReadPrompt resolves the active published version inside the project tied to the execution key.
Official SDKs
Use the official SDKs from trusted server-side, worker, or serverless code. They provide execution results, typed errors, and SSE parsing without exposing your execution key to the browser.
Install an SDK
Install the TypeScript SDK
bash
npm install @readprompt/sdkExecute by prompt name
TypeScript SDK request
typescript
import { ReadPrompt } from "@readprompt/sdk";
const readprompt = new ReadPrompt({
apiKey: process.env.READPROMPT_EXECUTION_API_KEY!,
});
const result = await readprompt.execute<{ summary: string }>(
"company-brief",
{ company: "Acme" },
);
console.log(result.data.summary);
console.log(result.meta.resolved_model);Authentication
Every execution request uses a project-scoped API key. Create it after signing in, then keep it in a server-side secret store or encrypted environment variable.
Executor base URL and required headers
text
Base URL: https://sdk.readprompt.dev/v1
Authorization: Bearer $READPROMPT_EXECUTION_API_KEY
Content-Type: application/jsonVariables and output contracts
ReadPrompt validates request variables before a model is called and validates the final response against the published output schema before it is returned to your application.
variablesmust be a JSON object that exactly satisfies the prompt version variables schema.- Required fields, types, enums, array items, and
additionalPropertiesrules are enforced. - The response
datashape is prompt-specific. Do not assume ananswerfield.
Example strict output schema
json
{
"type": "object",
"additionalProperties": false,
"required": ["summary"],
"properties": { "summary": { "type": "string" } }
}Successful response
json
{
"request_id": "73d676d1-d929-43b6-91f1-a5f9066eb7c8",
"data": { "summary": "Acme is ready for expansion." },
"meta": {
"prompt_id": "13ededb4-7e14-49b0-bc3c-729ad6e04f7b",
"prompt_name": "Company Brief",
"version_number": 3,
"requested_provider": "openai",
"requested_model": "gpt-5.4-mini",
"resolved_model": "openai/gpt-5.4-mini",
"fallback_used": false,
"latency_ms": 1321
}
}Routing and fallback
Your application does not choose a provider or model for each call. The published prompt version defines the enabled targets, routing mode, and fallback policy. Only enabled READY targets with an optimized artifact are eligible.
| Mode | First choice | Fallback |
|---|---|---|
round_robin | Rotates eligible targets in stable order | Continues the rotated order |
fastest | Lowest recent successful latency | Next lowest latency |
cheapest | Lowest catalog-derived token cost | Next lowest cost; a complete project price override takes precedence |
balanced | Combined cost and latency score | Next lowest combined score |
fixed | Configured primary target | Configured secondary target only |
Fallback may occur after an eligible target times out, fails, or returns output that does not satisfy your schema. Executor moves directly to the next candidate instead of retrying the same failing target.
Production checklist
- Keep API keys in a server-side secret manager.
- Create separate keys for staging, production, and background workloads.
- Validate end-user authorization before executing a prompt.
- Use application timeouts and bounded retries for transient failures.
- Log request IDs and execution metadata for traceability.
Compare active models, capabilities, pricing, and operational signals in the public catalog.
Planned for a future release with an isolated test mode. It will never require a browser to hold a live production execution key.