Skip to main content

Python SDK for Prism by Ssimplifi — the AI gateway that picks the model for you.

Project description

ssimplifi — Python SDK for Prism

pip install ssimplifi

Quick start

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
# 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)

# 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:

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:

# 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

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

ssimplifi-1.8.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

ssimplifi-1.8.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file ssimplifi-1.8.0.tar.gz.

File metadata

  • Download URL: ssimplifi-1.8.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for ssimplifi-1.8.0.tar.gz
Algorithm Hash digest
SHA256 830307dac5276a67eb3921e1c081c73e206cf6352ae1369d429a99e21d0b44a4
MD5 03ea71d200a2eca84e4b0068e2a51966
BLAKE2b-256 2c648d392d87c42a2a503c61197c168b091f943a54dc81731cbc74d46dab89ca

See more details on using hashes here.

File details

Details for the file ssimplifi-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: ssimplifi-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for ssimplifi-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f8a4d4d933bf304e82e672f9005cc098c5352c018a8a04607defcddbba59c36
MD5 4aa6c0a06f1581946e5fe62ee715d703
BLAKE2b-256 151119d9d3ea8c16989e8eabec91bd5f9b4d77ed6d7844c95dc904ce0a0ae74f

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