# Get draft version (always the latest unreleased changes)draft = client.get_prompt("@workspace/my-prompt:v0")# Get specific published versionv1 = client.get_prompt("@workspace/my-prompt:v1")v2 = client.get_prompt("@workspace/my-prompt:v2")# Get latest published versionlatest = client.get_prompt("@workspace/my-prompt:latest")
Version v0 is reserved for drafts. Published versions start at v1.
prompt = client.get_prompt("@workspace/my-prompt:v1")# Basic infoprint(f"Title: {prompt.title}")print(f"Description: {prompt.description}")# Package informationprint(f"Workspace: {prompt.namespace}")print(f"Slug: {prompt.slug}")print(f"Version: {prompt.version}")print(f"Full package name: {prompt.package_name}")# Version statusif prompt.is_draft: print("This is a draft version")else: print("This is a published version")
Prompts support both attribute and dictionary access:
Copy
prompt = client.get_prompt("@workspace/test:v1")# Attribute access (recommended)print(prompt.title)print(prompt.generator)# Dictionary accessprint(prompt['title'])print(prompt.get('description', 'No description'))# Check if field existsif 'system' in prompt: print(prompt['system'])# Get all data as dictdata = prompt.to_dict()
def migrate_to_latest(package_base: str): """Migrate from current version to latest""" current = client.get_prompt(f"{package_base}:v1") latest = client.get_prompt(f"{package_base}:latest") if current.version != latest.version: print(f"New version available: {latest.version}") print(f"Title: {latest.title}") return latest return current# Usageprompt = migrate_to_latest("@workspace/customer-support")
Using latest in production means your application behavior changes when prompts are updated.
Test Drafts Before Publishing
Use v0 (draft) for development and testing:
Copy
import osENV = os.getenv("ENVIRONMENT", "production")if ENV == "development": # Use draft in development prompt = client.get_prompt("@workspace/support:v0")else: # Use specific version in production prompt = client.get_prompt("@workspace/support:v1")
Handle Missing Optional Fields
Not all prompts have system or critique prompts:
Copy
# ✅ Good: Check before usingif prompt.has_system_prompt(): system = prompt.systemelse: system = "You are a helpful assistant."# ✅ Good: Use .get() with defaultcritique = prompt.get('critique', '')# ❌ Bad: Assume field existssystem = prompt.system # May be empty string