# Prompty Python SDK
Python client for interacting with the Prompty API to fetch real-time prompts for AI agents.
## Installation
```bash
pip install prompty-sdk
```
Or install from source:
```bash
cd python-sdk
pip install -e .
```
## Usage
```python
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
```python
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
```python
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
            
         
        Raw data
        
            {
    "_id": null,
    "home_page": null,
    "name": "kaenova-prompty",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "prompty, ai, prompt, management, sdk",
    "author": "Prompty Team",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/2b/8b/b780296d6faaa6e429ce0ed1f56874645b97aac1e2341281a5dfe93a4591/kaenova_prompty-20251102.15.9.tar.gz",
    "platform": null,
    "description": "# Prompty Python SDK\n\nPython client for interacting with the Prompty API to fetch real-time prompts for AI agents.\n\n## Installation\n\n```bash\npip install prompty-sdk\n```\n\nOr install from source:\n\n```bash\ncd python-sdk\npip install -e .\n```\n\n## Usage\n\n```python\nfrom prompty import PromptyClient\n\n# Initialize the client\nclient = PromptyClient(\n    base_url='https://your-prompty-instance.com',\n    project_id='your-project-id',\n    api_key='pk_your_api_key_here'\n)\n\n# Get the active prompt for an agent\nprompt = client.get_prompt('customer-support-agent')\nprint(prompt)\n# Output: \"You are a helpful customer support assistant...\"\n\n# Get detailed information about the prompt\ndetails = client.get_prompt_details('customer-support-agent')\nprint(details['prompt_text'])\nprint(details['prompt_id'])\nprint(details['updated_at'])\n```\n\n## API Reference\n\n### PromptyClient\n\nInitialize a Prompty client.\n\n**Parameters:**\n- `base_url` (str): The base URL of your Prompty instance\n- `project_id` (str): Your project ID\n- `api_key` (str): Your API key\n\n### get_prompt(agent_name)\n\nGet the active prompt text for an agent.\n\n**Parameters:**\n- `agent_name` (str): The name of the agent\n\n**Returns:**\n- `str`: The prompt text\n\n**Raises:**\n- `ValueError`: If the API key is invalid or agent not found\n- `RuntimeError`: If there's a server error\n\n### get_prompt_details(agent_name)\n\nGet detailed information about the active prompt.\n\n**Parameters:**\n- `agent_name` (str): The name of the agent\n\n**Returns:**\n- `dict`: Dictionary containing:\n  - `prompt_text` (str): The prompt text\n  - `prompt_id` (str): The prompt ID\n  - `updated_at` (str): When the prompt was created/updated\n  - `agent_name` (str): The agent name\n\n**Raises:**\n- `ValueError`: If the API key is invalid or agent not found\n- `RuntimeError`: If there's a server error\n\n## Example: Using with OpenAI\n\n```python\nfrom prompty import PromptyClient\nimport openai\n\n# Initialize Prompty client\nprompty = PromptyClient(\n    base_url='https://your-prompty-instance.com',\n    project_id='your-project-id',\n    api_key='pk_your_api_key_here'\n)\n\n# Get the prompt from Prompty\nsystem_prompt = prompty.get_prompt('customer-support-agent')\n\n# Use it with OpenAI\nresponse = openai.ChatCompletion.create(\n    model=\"gpt-4\",\n    messages=[\n        {\"role\": \"system\", \"content\": system_prompt},\n        {\"role\": \"user\", \"content\": \"How do I reset my password?\"}\n    ]\n)\n\nprint(response.choices[0].message.content)\n```\n\n## Error Handling\n\nThe SDK raises the following exceptions:\n\n- `ValueError`: When the API key is invalid or the requested agent/prompt is not found\n- `RuntimeError`: When there's a server error or network issue\n\n```python\ntry:\n    prompt = client.get_prompt('my-agent')\nexcept ValueError as e:\n    print(f\"Invalid request: {e}\")\nexcept RuntimeError as e:\n    print(f\"Server error: {e}\")\n```\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python SDK for Prompty - Real-time prompt management for AI agents",
    "version": "20251102.15.9",
    "project_urls": {
        "Homepage": "https://github.com/kaenova/prompty",
        "Repository": "https://github.com/kaenova/prompty"
    },
    "split_keywords": [
        "prompty",
        " ai",
        " prompt",
        " management",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7f99fb554bd5155804a2250b0876a9842dba4401d19cf5817cfcfa114c8e9ec2",
                "md5": "acf29c40016bb56eb56991b91fac6afd",
                "sha256": "b8c8b35b238101fa6b24fa749cb382f3ed853fd62c6ab6320477551929d110f0"
            },
            "downloads": -1,
            "filename": "kaenova_prompty-20251102.15.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acf29c40016bb56eb56991b91fac6afd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3866,
            "upload_time": "2025-11-02T15:09:17",
            "upload_time_iso_8601": "2025-11-02T15:09:17.523724Z",
            "url": "https://files.pythonhosted.org/packages/7f/99/fb554bd5155804a2250b0876a9842dba4401d19cf5817cfcfa114c8e9ec2/kaenova_prompty-20251102.15.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2b8bb780296d6faaa6e429ce0ed1f56874645b97aac1e2341281a5dfe93a4591",
                "md5": "6d01deaf429be9711101a7cd7cf1c99a",
                "sha256": "46ab3cfa780bd191857de3410f978b0a237b26d59fc39c6a16a226c80fa47744"
            },
            "downloads": -1,
            "filename": "kaenova_prompty-20251102.15.9.tar.gz",
            "has_sig": false,
            "md5_digest": "6d01deaf429be9711101a7cd7cf1c99a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3395,
            "upload_time": "2025-11-02T15:09:18",
            "upload_time_iso_8601": "2025-11-02T15:09:18.372822Z",
            "url": "https://files.pythonhosted.org/packages/2b/8b/b780296d6faaa6e429ce0ed1f56874645b97aac1e2341281a5dfe93a4591/kaenova_prompty-20251102.15.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-02 15:09:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kaenova",
    "github_project": "prompty",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kaenova-prompty"
}