plp-client
Official Python client for PLP (Prompt Library Protocol).
Installation
pip install plp-client
Quick Start
from plp_client import PLPClient, PromptInput
# Initialize client
client = PLPClient("https://prompts.goreal.ai", api_key="your-api-key")
# Get latest version of a prompt
prompt = client.get("marketing/welcome-email")
print(prompt.content) # "Hello {{name}}..."
# Get specific version
old_prompt = client.get("marketing/welcome-email", "1.0.0")
# Save a new prompt
client.put("support/faq-bot", PromptInput(
content="You are a helpful FAQ bot. Answer: {{question}}",
meta={"version": "1.0.0", "author": "yoad"}
))
# Delete a prompt
client.delete("deprecated/old-prompt")
API Reference
PLPClient
Constructor
PLPClient(base_url: str, api_key: Optional[str] = None,
headers: Optional[Dict[str, str]] = None, timeout: int = 10)
Parameters:
base_url(str): Base URL of the PLP serverapi_key(str, optional): Optional Bearer token for authenticationheaders(dict, optional): Additional HTTP headerstimeout(int): Request timeout in seconds (default: 10)
Methods
get(prompt_id, version=None)
Retrieve a prompt by ID and optional version.
def get(prompt_id: str, version: Optional[str] = None) -> PromptEnvelope
prompt_id(str): Unique prompt identifier (e.g.,"marketing/welcome-email")version(str, optional): Optional version string (e.g.,"1.2.0"). If omitted, returns latest.
Returns: PromptEnvelope
Raises: PLPError if not found (404) or other errors
put(prompt_id, input)
Create or update a prompt (idempotent upsert).
def put(prompt_id: str, input: PromptInput) -> PromptEnvelope
prompt_id(str): Unique prompt identifierinput(PromptInput): Object withcontentand optionalmeta
Returns: The saved PromptEnvelope
delete(prompt_id)
Delete a prompt and all its versions.
def delete(prompt_id: str) -> None
prompt_id(str): Unique prompt identifier
Returns: None (204 No Content on success)
Aliases
fetch(prompt_id, version=None) # Alias for get()
save(prompt_id, input) # Alias for put()
Data Classes
PromptEnvelope
class PromptEnvelope:
id: str
content: str
meta: Dict[str, Any]
PromptInput
class PromptInput:
content: str
meta: Dict[str, Any]
Error Handling
from plp_client import PLPClient, PLPError
client = PLPClient("https://prompts.goreal.ai")
try:
prompt = client.get("missing/prompt")
except PLPError as e:
print(f"Error: {e}")
print(f"Status code: {e.status_code}")
Examples
Using with OpenAI
from plp_client import PLPClient
from openai import OpenAI
plp = PLPClient("https://prompts.goreal.ai")
openai = OpenAI()
prompt = plp.get("assistant/code-reviewer")
response = openai.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt.content}],
temperature=prompt.meta.get("model_config", {}).get("temperature", 0.7)
)
print(response.choices[0].message.content)
Using with Anthropic
from plp_client import PLPClient
import anthropic
plp = PLPClient("https://prompts.goreal.ai")
client = anthropic.Anthropic()
prompt = plp.get("creative/story-generator")
message = client.messages.create(
model="claude-3-opus-20240229",
max_tokens=prompt.meta.get("model_config", {}).get("max_tokens", 1024),
messages=[{"role": "user", "content": prompt.content}]
)
print(message.content)
Context Manager
from plp_client import PLPClient
with PLPClient("https://prompts.goreal.ai") as client:
prompt = client.get("my/prompt")
print(prompt.content)
# Session is automatically closed
Development
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=plp_client
# Format code
black src/ tests/
# Type checking
mypy src/
License
MIT © GoReal.AI
Contributing
See CONTRIBUTING.md
Learn More
Metadata
Release files for plp-client 1.0.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 |
|---|---|---|---|---|
| plp_client-1.0.0.tar.gz | 8.0 kB | Without provenance | Details for plp_client-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plp_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for plp_client-1.0.0-py3-none-any.whl |
Total release size: 14.2 kB
Release files / plp_client-1.0.0.tar.gz
| Download URL | plp_client-1.0.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99ae8b28bdb0085828f11a09a8a6786a087ad818b5e119511c0845d40571e877
|
|
BLAKE2b-256 checksum How to use checksums |
f037a8ce39198a52f6965a8c4c829d43e7b2a3e7097bc77c56a57f97b086b541
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / plp_client-1.0.0-py3-none-any.whl
| Download URL | plp_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
601c6b897f470b278b80c4a04eaee2663925ecb65d2af9e2f56af75a69682447
|
|
BLAKE2b-256 checksum How to use checksums |
b0aee3e723c99537c55cbf9e2730e05985ef9bd2a2fc5e7d929821c0696f1045
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for plp-client 1.0.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.