PromptClient is the SDK interface to this library, available in both the TypeScript and Python SDKs with the same method names and behavior (Python uses snake_case).
Getting a PromptClient
The PromptClient is available two ways: from the initialized zespan client, or by constructing it directly.
Fetching a prompt
get(name, options?) (TypeScript) / get(name, ...) (Python) fetches a prompt by name. By default it returns the latest version. Results are cached locally for 5 minutes.
string
required
The name of the prompt to fetch.
number
Fetch a specific version number. Mutually exclusive with
label.string
Fetch the version currently associated with this label (e.g.
"production", "staging", "canary"). Mutually exclusive with version.boolean
default:"true"
When
true, the result is cached locally for 5 minutes. Set to false to bypass the cache for this call.object
A local fallback to use if the fetch fails and there’s no usable cache. Shape:
{ type?: "text" | "chat", prompt: <content, same shape as a real prompt's prompt field>, config?: object } (TypeScript) or the equivalent dict with the same keys (Python). See Handling fetch failures below.Handling fetch failures
Ifget() can’t reach the prompt library — a network blip, an outage, whatever — it degrades gracefully instead of throwing immediately:
- If an earlier successful fetch for the same prompt (same name, version, and label) is still in the local cache, that cached copy is served even if it’s past the 5-minute TTL.
- If there’s no cached copy at all, and you passed a
fallbackoption, the client synthesizes a prompt-like result from it that you can still callcompile()on. - If neither a stale cache nor a fallback is available,
get()raises the underlying fetch error — the original behavior.
isFallback: true (TypeScript) or is_fallback: True (Python) whenever it came from the fallback option, so you can detect degraded mode and log or alert on it. A stale-cache hit is not flagged — from the caller’s perspective it’s just a slightly older copy of the real prompt.
Passing
cache: false (TypeScript) or cache=False (Python) disables both caching and stale-cache serving for that call. A fetch failure with caching disabled goes straight to the fallback option (if provided) or raises — it will not return a previously cached value from an earlier call, even if one exists.Compiling prompts with variables
compile(prompt, variables, placeholders?) substitutes {{variable}} placeholders in a prompt’s text with the values you provide, and — for chat-type prompts — splices in any message placeholders.
chat-type prompts, compile returns the resolved message array directly — no parsing required:
object
required
The prompt returned from
get() (including a fallback result — see Handling fetch failures above).object
A map of
{{variable}} names to the values that replace them. Applied to every message’s content in a chat prompt, including messages inserted via placeholders.object
Only relevant for
chat-type prompts. Maps a placeholder name to the array of { role, content } messages to splice into that slot. See Composing messages with placeholders below.Composing messages with placeholders
Achat-type prompt’s message array can include a placeholder — a named slot, distinct from a regular { role, content } message — for content you only know at call time, such as conversation history or retrieved context. Author the placeholder once when you create() the prompt, then fill it in on every compile() call.
{{variable}} substitution still applies to every message, whether it was authored directly in the prompt or supplied via placeholders.
Listing prompts
list(nameFilter?) (TypeScript) / list(name_filter=None) (Python) returns all prompts in your project. Optionally filter by a name substring.
Creating a new prompt version
create(params) (TypeScript) / create(...) (Python) creates a new prompt version. Each call creates a new version number — existing versions are never modified.
string
required
The prompt name. Must match the name of an existing prompt to add a version, or creates a new prompt if it does not exist.
string
required
"text" for a plain string prompt with {{variable}} placeholders, or "chat" for an array of messages. (Python’s keyword argument is named prompt_type since type is a reserved builtin.)any
required
The prompt content. A string for
text type; an array of message objects for chat type.object
Suggested model configuration (model, temperature, max_tokens). Stored with the prompt for reference but not enforced by the SDK.
string[]
Labels to apply to this version immediately on creation (e.g.
["staging"]).string[]
Searchable tags for organizing prompts in the dashboard.
string
Human-readable description of what changed in this version. Appears in the version history view. (Python:
commit_message.)Updating labels
updateLabels(name, version, labels) (TypeScript) / update_labels(name, version, labels) (Python) replaces all labels on a specific version. Use this to promote a version from staging to production.
Labels are not exclusive by default. The same label (e.g.
"production") can exist on multiple versions simultaneously. If you want a single canonical production version, update the old version’s labels to remove "production" before applying it to the new version.Clearing the cache
The local cache has a 5-minute TTL. CallclearCache() (TypeScript) / clear_cache() (Python) to invalidate it manually — useful after creating a new version or updating labels in the same process.
Managing prompts from an AI assistant
Zespan’s hosted MCP server exposes prompt management as tools an AI assistant — Claude Desktop, Cursor, or any MCP client — can call directly: listing prompts, fetching a prompt’s resolved content and detected{{variables}}, creating a new version, updating tags, and setting or moving a label (e.g. promoting a version to production).
See the Zespan MCP guide for the full tool list and client setup.

