Python SDK

The superprompts package fetches prompts at runtime, fills in variables and caches reads. It uses only the standard library, so it drops into any Python 3.9+ project.

Install

pip install superprompts

Fetch a prompt

import os
from superprompts import SuperPrompts

sp = SuperPrompts(api_key=os.environ["SUPERPROMPTS_API_KEY"])

prompt = sp.get_prompt("<PROMPT_ID>", variables={"customer": "Ada"})
print(prompt.prompt)        # assembled system message
print(prompt.version[:7])   # content hash that was served

get_prompt serves the published version by default. Pass version="latest" in staging to read the newest draft, or a version hash to pin one.

With OpenAI

from openai import OpenAI

prompt = sp.get_prompt("<PROMPT_ID>", variables={"customer": user.name})

completion = OpenAI().chat.completions.create(
    model="gpt-5",
    messages=[
        {"role": "system", "content": prompt.prompt},
        {"role": "user", "content": "I need help with my order"},
    ],
    tools=prompt.tools or None,
)

With Anthropic

import anthropic

prompt = sp.get_prompt("<PROMPT_ID>")

message = anthropic.Anthropic().messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    system=prompt.prompt,
    messages=[{"role": "user", "content": "I need help with my order"}],
)

Write and publish

created = sp.create_prompt(
    "Onboarding email",
    markdown="# Role\nYou write {{ tone }} emails.",
)

sp.update_prompt(
    created["id"],
    sections=[{"title": "Role", "content": "You write short emails."}],
    message="tighten",
)

sp.publish_prompt(created["id"])              # publish latest
sp.publish_prompt(created["id"], "18bab0e")   # or roll back to a version

Options

SuperPrompts(
    api_key="sp_...",
    base_url="https://superprompts.app",
    cache_ttl=5.0,   # seconds; 0 disables the in-memory cache
    guard=True,      # append Prompt Guard to fetched prompts
    timeout=10.0,
)

Failures raise SuperPromptsError with a .status attribute and the server's message. strict=True on get_prompt raises KeyError when a variable has no value.

Next steps