partython-brain
Python SDK for the Partython AI brain — embed conversational, sales-aware AI in your app or backend.
pip install partython-brain
Quick start
from partython_brain import Brain
import os
brain = Brain(api_key=os.environ["PARTYTHON_API_KEY"])
result = brain.respond(
channel="web",
channel_user_id="user-abc",
message_text="I'm planning a 5-year-old's birthday with 12 guests — any unicorn theme ideas?",
)
print(result["response"])
# → "A unicorn theme for a 5-year-old with 12 guests — fun! Let me show you our..."
API
Brain(api_key, base_url=None, timeout=30, session=None)
| Param | Default | Description |
|---|---|---|
| api_key | (required) | Your pk_live_... API key |
| base_url | https://brain.partython.com |
Override for self-hosted |
| timeout | 30.0 |
Per-call timeout in seconds |
| session | new requests.Session |
Custom session for retries / connection pool |
brain.respond(...)
Keyword args (all required unless noted):
channel: str—"web"|"whatsapp"|"sms"|"api"...channel_user_id: str— stable id for the conversation participantmessage_text: str— the customer's messagemetadata: dict | None— optional pass-through metadatadedup_key: str | None— idempotency key (webhook event id)has_image: bool— hint for the smart router
Returns dict with response, assistant_name, request_id, metadata.
Errors
from partython_brain import BrainAuthError, BrainRateLimitError
try:
brain.respond(...)
except BrainRateLimitError as e:
# back off — retry-after info is in e.body
...
except BrainAuthError as e:
# key invalid or revoked
...
| Exception | When it fires |
|---|---|
BrainAuthError |
401 / 403 — key invalid, revoked, or no scope |
BrainRateLimitError |
429 — per-key per-minute limit hit |
BrainNotFoundError |
404 — tenant misconfigured |
BrainServerError |
5xx upstream |
BrainNetworkError |
Network or timeout |
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
partython_brain-1.0.0.tar.gz
(5.2 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 partython_brain-1.0.0.tar.gz.
File metadata
- Download URL: partython_brain-1.0.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97c6e325011f226c2698388f0987b0f2a51399e04315a744f93b9fa2ec3202fa
|
|
| MD5 |
c9bf6ea101f75355c7975dc2165d45ce
|
|
| BLAKE2b-256 |
317f84082550678506d7bc85ff1fc9701b1da4d844b74d135124999a06c451f4
|
File details
Details for the file partython_brain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: partython_brain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
210e842305a8ed67a3479fee6c53b69dde1deb0768456ad0f4f7561e645fa627
|
|
| MD5 |
836754cfbad2e3001fef9bb31136a7d6
|
|
| BLAKE2b-256 |
eacf925cf2d1ed8cdbbb506149e7a1031973d463d9d2103e1eef1807512a8609
|