Official Python SDK for Promptly - LLM cost optimization proxy
Project description
promptly-sdk
Official Python SDK for Promptly - LLM cost optimization proxy.
Install
pip install promptly-sdk
Quick Start
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
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
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:
import openai
from promptly import wrap
client = wrap(openai.OpenAI(api_key="sk-your-openai-key"))
# All calls now go through Promptly
Configuration
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
promptly_sdk-0.1.1.tar.gz
(2.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptly_sdk-0.1.1.tar.gz.
File metadata
- Download URL: promptly_sdk-0.1.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b83923bdc28efb1a4e0572bf85d77121dbaf0f49857d5f0269ddf243791dee4
|
|
| MD5 |
e84731761b3e465c20b82e67307ffb3c
|
|
| BLAKE2b-256 |
15ed21986c5c5512e0ffc6716dc2239e5788957e72f316aa40502acd06f817ae
|
File details
Details for the file promptly_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: promptly_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da0abcea02ec8ebda7e3e47f3817e7df56f89d1cc39129eff7416f5da303ce68
|
|
| MD5 |
75a4d14e35772bbd6270853f65adffb9
|
|
| BLAKE2b-256 |
87eca05ad46543bf3613ff838e82b93bae099380147907033c0313395db5592b
|