Skip to main content

Python SDK for Prompty - Real-time prompt management for AI agents

Project description

Prompty Python SDK

Python client for interacting with the Prompty API to fetch real-time prompts for AI agents.

Installation

pip install prompty-sdk

Or install from source:

cd python-sdk
pip install -e .

Usage

from prompty import PromptyClient

# Initialize the client
client = PromptyClient(
    base_url='https://your-prompty-instance.com',
    project_id='your-project-id',
    api_key='pk_your_api_key_here'
)

# Get the active prompt for an agent
prompt = client.get_prompt('customer-support-agent')
print(prompt)
# Output: "You are a helpful customer support assistant..."

# Get detailed information about the prompt
details = client.get_prompt_details('customer-support-agent')
print(details['prompt_text'])
print(details['prompt_id'])
print(details['updated_at'])

API Reference

PromptyClient

Initialize a Prompty client.

Parameters:

  • base_url (str): The base URL of your Prompty instance
  • project_id (str): Your project ID
  • api_key (str): Your API key

get_prompt(agent_name)

Get the active prompt text for an agent.

Parameters:

  • agent_name (str): The name of the agent

Returns:

  • str: The prompt text

Raises:

  • ValueError: If the API key is invalid or agent not found
  • RuntimeError: If there's a server error

get_prompt_details(agent_name)

Get detailed information about the active prompt.

Parameters:

  • agent_name (str): The name of the agent

Returns:

  • dict: Dictionary containing:
    • prompt_text (str): The prompt text
    • prompt_id (str): The prompt ID
    • updated_at (str): When the prompt was created/updated
    • agent_name (str): The agent name

Raises:

  • ValueError: If the API key is invalid or agent not found
  • RuntimeError: If there's a server error

Example: Using with OpenAI

from prompty import PromptyClient
import openai

# Initialize Prompty client
prompty = PromptyClient(
    base_url='https://your-prompty-instance.com',
    project_id='your-project-id',
    api_key='pk_your_api_key_here'
)

# Get the prompt from Prompty
system_prompt = prompty.get_prompt('customer-support-agent')

# Use it with OpenAI
response = openai.ChatCompletion.create(
    model="gpt-4",
    messages=[
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": "How do I reset my password?"}
    ]
)

print(response.choices[0].message.content)

Error Handling

The SDK raises the following exceptions:

  • ValueError: When the API key is invalid or the requested agent/prompt is not found
  • RuntimeError: When there's a server error or network issue
try:
    prompt = client.get_prompt('my-agent')
except ValueError as e:
    print(f"Invalid request: {e}")
except RuntimeError as e:
    print(f"Server error: {e}")

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

kaenova_prompty-20251102.15.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

kaenova_prompty-20251102.15.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file kaenova_prompty-20251102.15.1.tar.gz.

File metadata

  • Download URL: kaenova_prompty-20251102.15.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for kaenova_prompty-20251102.15.1.tar.gz
Algorithm Hash digest
SHA256 14796c5c82f1b3bc323b27844d598ed07d2412b3eebcad2785e06ebc56111263
MD5 797e6511a971d7e4589af8b1a506ece0
BLAKE2b-256 e95c0c6a95818966bb928b0765ec991ab105d4f4854fb92d18ed53a4d55d7e67

See more details on using hashes here.

File details

Details for the file kaenova_prompty-20251102.15.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kaenova_prompty-20251102.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a9f366dc9d33c6a299aa262af825b16c0082f28b28e463e4c80284c8ccf74fe
MD5 3861d92b28fe4fee6c32faac1384624a
BLAKE2b-256 e3045524f3d143bd5526f1647c36e8aea2f94cd92d095743407419428c0781a5

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