Metadata-Version: 2.4
Name: promptly-sdk
Version: 0.1.1
Summary: Official Python SDK for Promptly - LLM cost optimization proxy
Author-email: Promptly <contact@getpromptly.in>
License: MIT
Project-URL: Homepage, https://getpromptly.in
Project-URL: Documentation, https://getpromptly.in/docs
Project-URL: Repository, https://github.com/getpromptly/promptly-python
Keywords: llm,openai,cost-optimization,proxy,ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: openai>=1.0.0

# promptly-sdk

Official Python SDK for [Promptly](https://getpromptly.in) - LLM cost optimization proxy.

## Install

```bash
pip install promptly-sdk
```

## Quick Start

```python
from promptly import Promptly

client = Promptly(api_key="sk-promptly-...")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

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

## Streaming

```python
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a poem."}],
    stream=True,
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")
```

## Access Promptly Metadata

```python
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

meta = response.promptly_metadata
print(f"Saved: ${meta['savings']}")
print(f"Routed to: {meta['routed_model']}")
print(f"Cache hit: {meta['cache_hit']}")
```

## Wrap Existing Client

Already using the OpenAI SDK? Wrap it in one line:

```python
import openai
from promptly import wrap

client = wrap(openai.OpenAI(api_key="sk-your-openai-key"))
# All calls now go through Promptly
```

## Configuration

```python
client = Promptly(
    api_key="sk-promptly-...",
    base_url="https://api.getpromptly.in/v1",  # default
    timeout=30,                                  # seconds
    max_retries=2,                               # auto-retry on failure
)
```

## Requirements

- Python 3.8+
- `openai` >= 1.0.0
