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.9.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.9-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kaenova_prompty-20251102.15.9.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.9.tar.gz
Algorithm Hash digest
SHA256 46ab3cfa780bd191857de3410f978b0a237b26d59fc39c6a16a226c80fa47744
MD5 6d01deaf429be9711101a7cd7cf1c99a
BLAKE2b-256 2b8bb780296d6faaa6e429ce0ed1f56874645b97aac1e2341281a5dfe93a4591

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kaenova_prompty-20251102.15.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c8b35b238101fa6b24fa749cb382f3ed853fd62c6ab6320477551929d110f0
MD5 acf29c40016bb56eb56991b91fac6afd
BLAKE2b-256 7f99fb554bd5155804a2250b0876a9842dba4401d19cf5817cfcfa114c8e9ec2

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