Metadata-Version: 2.4
Name: ssimplifi
Version: 1.8.0
Summary: Python SDK for Prism by Ssimplifi — the AI gateway that picks the model for you.
Author-email: Ssimplifi <support@ssimplifi.com>
License: Apache-2.0
Project-URL: Homepage, https://ssimplifi.com
Project-URL: Documentation, https://ssimplifi.com/docs/sdks
Project-URL: Repository, https://github.com/ravirdp/prism
Project-URL: Issues, https://github.com/ravirdp/prism/issues
Keywords: ai,llm,gateway,openai,anthropic,prism,ssimplifi,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: openai<2.0,>=1.40
Requires-Dist: httpx>=0.27

# ssimplifi — Python SDK for Prism

```bash
pip install ssimplifi
```

## Quick start

```python
from ssimplifi import Prism

client = Prism(api_key="prism_sk_...")

response = client.chat.completions.create(
    messages=[{"role": "user", "content": "What's the capital of Australia?"}],
    mode="balanced",
)
print(response.choices[0].message.content)
```

That's it. The SDK extends the OpenAI Python client, pointed at Prism's base URL. Everything you already know about `openai` — streaming, retries, response shape — works identically.

## Prism-specific kwargs (what you get over plain `openai.OpenAI`)

| Kwarg | Header | What it does |
|---|---|---|
| `mode="eco" / "balanced" / "sport"` | `X-Prism-Mode` | Quality/cost mode for auto-routing |
| `model_prefer="claude-sonnet"` | `X-Prism-Model-Prefer` | Force a specific model (overrides auto-routing) |
| `session_id="user-abc"` | `X-Prism-Session` | Multi-turn memory; persists across model switches |
| `cache="off" / "exact" / "semantic"` | `X-Prism-Cache` | Cache behavior for this request |
| `request_tags={"feature": "search"}` | `X-Prism-Request-Tags` | Attribution tags for usage breakdown |

```python
# Multi-turn chat with session memory
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "Remember: my name is Ravi"}],
    session_id="user-abc",
)
# Next call: no need to resend history
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "What's my name?"}],
    session_id="user-abc",
)
print(response.choices[0].message.content)  # "Your name is Ravi."
```

## Admin methods (Pro/Team tier)

```python
# Live model catalog
catalog = client.models.list(provider="groq")  # filter optional
print(catalog["summary"])  # {"provider_count_active": 7, "model_count_total": 23, ...}

# Your usage
print(client.usage.summary(days=7))

# Cache stats
print(client.cache.stats(days=7))

# API keys
print(client.keys.list())
new = client.keys.create(name="staging-app")
print(new["key"])  # full secret shown ONCE
client.keys.revoke(key_id="key-id-from-list")

# Identity + balance
print(client.whoami())
print(client.balance())
```

## Submitting feedback

The chat response includes an `X-Prism-Feedback-Id` header you can use to submit thumbs / ratings later:

```python
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "..."}],
    mode="balanced",
)

# Pull the feedback id from the response object
feedback_id = response.response.headers.get("X-Prism-Feedback-Id")

# Later (e.g. when the user clicks thumbs up in your UI)
client.submit_feedback(feedback_id=feedback_id, thumb="up")
client.submit_feedback(feedback_id=feedback_id, rating=5, comment="great")
```

## Drop-in replacement for plain OpenAI

If you've already got code using `openai.OpenAI`, change two lines:

```python
# Before
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# After
from ssimplifi import Prism
client = Prism(api_key=os.environ["PRISM_API_KEY"])
```

Every `client.chat.completions.create(...)` call you wrote continues to work. Add `mode=` and you've got auto-routing + caching + multi-provider failover, no code rewrite.

## Compatibility

- Python 3.10+
- Builds on top of `openai>=1.40,<2.0` and `httpx>=0.27`
- Tied to the Prism backend `/v1/` major version — SDK 1.x works with any backend 1.x.

## License

Apache-2.0
