readprompt
The server-side Python SDK for executing published ReadPrompt prompts.
This package sends an execution API key. Use it only in trusted server-side, worker, or serverless code. Do not include it in browser code, mobile apps, or client-side analytics.
Install
pip install readprompt
Requires Python 3.10 or later.
Synchronous client
import os
from readprompt import ReadPrompt
with ReadPrompt(api_key=os.environ["READPROMPT_EXECUTION_API_KEY"]) as readprompt:
result = readprompt.execute(
"product-answer",
{"question": "What is ReadPrompt?"},
)
print(result.data["answer"])
print(result.meta.resolved_model)
The returned data exactly matches the published prompt version's output schema. Its shape is prompt-specific, so do not assume an answer field universally.
Execute by ID
result = readprompt.execute_by_id(
"13ededb4-7e14-49b0-bc3c-729ad6e04f7b",
{"question": "What is ReadPrompt?"},
)
Async client and streaming
import os
from readprompt import AsyncReadPrompt, ReadPromptStreamError
async def main() -> None:
try:
async with AsyncReadPrompt(api_key=os.environ["READPROMPT_EXECUTION_API_KEY"]) as readprompt:
async for event in readprompt.stream(
"product-answer",
{"question": "What is ReadPrompt?"},
):
if event.type == "delta":
print(event.text, end="", flush=True)
else:
print("\nValidated output:", event.result.data)
except ReadPromptStreamError as error:
print(error.code, error)
raise
Only the terminal complete event carries schema-validated application data. delta text is partial model output and may be incomplete JSON. A terminal SSE error becomes ReadPromptStreamError.
Errors
from readprompt import ReadPromptApiError
try:
result = readprompt.execute("product-answer", {"question": "Hello"})
except ReadPromptApiError as error:
if error.status_code == 429:
print(f"Retry after {error.retry_after_seconds or 'a short delay'} seconds.")
raise
The SDK does not automatically retry executions: a retry may duplicate model work or cost. Handle retries in your application only when repeating the operation is safe.
Configuration
The default Executor base URL is https://sdk.readprompt.dev/v1. For local development or tests:
readprompt = ReadPrompt(
api_key=os.environ["READPROMPT_EXECUTION_API_KEY"],
base_url="http://127.0.0.1:8000/v1",
)
See the ReadPrompt application documentation for prompt publishing, variable schemas, output schemas, API-key lifecycle, routing, and rate limits.
Metadata
Release files for readprompt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| readprompt-0.1.0.tar.gz | 10.5 kB | Without provenance | Details for readprompt-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| readprompt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for readprompt-0.1.0-py3-none-any.whl |
Total release size: 19.8 kB
Release files / readprompt-0.1.0.tar.gz
| Download URL | readprompt-0.1.0.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e461f4d1a4bcae77e969daf05a7cc0e6ff08c2fd8b04dc108cc7ca83edbc02f1
|
|
BLAKE2b-256 checksum How to use checksums |
f1878542a5f04d9fdcf5fff95bb3ab0d58a7d4d1cb4c42d6001f9d8a95d5d007
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / readprompt-0.1.0-py3-none-any.whl
| Download URL | readprompt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afaf6b375877935e2c23ddcc9cc4472f700eef8680f2c6224d3a367ecd6c63fb
|
|
BLAKE2b-256 checksum How to use checksums |
892e866389bca0c5ce7be9a34ae89de187a35c9b09fa21155f09e09ba7994771
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for readprompt 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.