Skip to main content

The universal prompt SDK. Fetch prompts from any PLP-compliant library and use them with any AI provider.

Project description

Echostash SDK for Python

The universal prompt SDK. Fetch prompts from any PLP-compliant library and use them with any AI provider.

Installation

pip install echostash

Quick Start

from echostash import Echostash
from openai import OpenAI

# Connect to any PLP-compliant server
es = Echostash("https://api.echostash.com", api_key="sk_...")

# Fetch a prompt and use with OpenAI
prompt = es.prompt("welcome-email").get()
message = prompt.with_vars(name="Alice").openai()

client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[message]
)

The Fluent API

The SDK is designed to be intuitive and chainable:

# Fetch + substitute + convert in one line
msg = es.prompt("welcome").vars(name="Alice").openai()

# Or step by step
prompt = es.prompt("welcome").get()
rendered = prompt.with_vars(name="Alice")
message = rendered.openai()

# Fetch a specific version
v1 = es.prompt("welcome").version("1.0.0").get()

# Short version alias
v2 = es.prompt("welcome").v("2.0.0").get()

Provider Support

OpenAI

from openai import OpenAI

message = prompt.with_vars(name="Alice").openai(role="system")
config = prompt.openai_config()

client = OpenAI()
response = client.chat.completions.create(
    **config,
    messages=[message]
)

Anthropic

import anthropic

# As user message
message = prompt.with_vars(name="Bob").anthropic()

# As system message (Anthropic handles system separately)
system = prompt.anthropic_system()
config = prompt.anthropic_config()

client = anthropic.Anthropic()
response = client.messages.create(
    **config,
    system=system,
    messages=[{"role": "user", "content": "Hello!"}]
)

Google / Gemini

message = prompt.google(role="user")
# or
message = prompt.gemini()

config = prompt.google_config()

Vercel AI SDK (for Node.js interop)

message = prompt.vercel(role="system")

LangChain

from langchain.prompts import PromptTemplate

# As message
message = prompt.langchain(message_type="human")

# As template (with input variables)
template, input_variables = prompt.langchain_template()
prompt_template = PromptTemplate.from_template(template)

Connect to Any PLP Server

The SDK works with any PLP-compliant prompt library:

import os

# Echostash Cloud
es = Echostash("https://api.echostash.com", api_key="sk_...")

# Local PLP server
local = Echostash("http://localhost:3000")

# Your company's prompt registry
corp = Echostash(
    "https://prompts.mycompany.com",
    api_key=os.environ["PROMPT_API_KEY"]
)

# Any PLP-compliant service
other = Echostash("https://plp.example.com")

Working with Prompts

Fetch Prompts

# Latest version
prompt = es.prompt("marketing/welcome").get()

# Specific version
v1 = es.prompt("marketing/welcome").version("1.0.0").get()

# With variables pre-set
prompt = es.prompt("welcome").vars(name="Alice").get()

Access Content

prompt = es.prompt("welcome").get()

# Raw content (string or list of ContentBlock)
raw = prompt.raw()

# As plain text
text = prompt.text()

# As string (same as text)
print(str(prompt))

Save Prompts

es.save(
    "my-new-prompt",
    content="Hello {{name}}!",
    meta={
        "version": "1.0.0",
        "author": "me"
    }
)

Delete Prompts

es.delete("my-old-prompt")

Server Discovery

info = es.discover()
print(info["plp_version"])   # "1.0"
print(info["capabilities"])  # {"versioning": True, ...}

Context Manager Support

with Echostash("https://api.echostash.com", api_key="sk_...") as es:
    prompt = es.prompt("welcome").get()
    # Connection is properly closed after the block

Type Hints

Full type hint support:

from echostash import (
    Prompt,
    PromptContent,
    PromptMeta,
    ModelConfig,
    LoadedPrompt,
)
from echostash.types import (
    OpenAIMessage,
    AnthropicMessage,
    GoogleMessage,
    VercelMessage,
    LangChainMessage,
)

Advanced: Direct Provider Functions

For advanced use cases, you can import provider functions directly:

from echostash.providers import (
    to_openai,
    to_anthropic,
    to_google,
    to_vercel,
    to_langchain,
    extract_openai_config,
)

content = "Hello {{name}}!"
message = to_openai(content, role="system")

Configuration

es = Echostash(
    "https://api.echostash.com",

    # API key for authentication
    api_key="sk_...",

    # Custom headers
    headers={
        "X-Custom-Header": "value"
    },

    # Request timeout (seconds)
    timeout=10,

    # Default parameter symbol for variable substitution
    default_parameter_symbol="{{}}"
)

Error Handling

from echostash import EchostashError

try:
    prompt = es.prompt("not-found").get()
except EchostashError as e:
    print(e.args[0])      # "HTTP 404"
    print(e.status_code)  # 404

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

echostash-1.0.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

echostash-1.0.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file echostash-1.0.0.tar.gz.

File metadata

  • Download URL: echostash-1.0.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for echostash-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a5925879c09d2641621e8360e6a365e689604f8f2aa6b72869dad618e34fc9e1
MD5 0b054300ca3afe90b6af795c311aea5b
BLAKE2b-256 a0b1fcf5ed4ad6a336808856f94e914786858f25d8d246c4653c743172f289e0

See more details on using hashes here.

File details

Details for the file echostash-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: echostash-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for echostash-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad1d3b3f443c2ad156c23154104afca312c7e9d7e6e2eaf348b13767d1c1adbc
MD5 6b460b71abc6917ab64aa29001b2a630
BLAKE2b-256 8c30dcf94fe3bcb8fbe0eb7612549f3baa474390b80118c83bc636f8f1b01cc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page