Python SDK for connecting text-based agents to the Pipbit platform.
Project description
Pipbit Python SDK
pipbit is the Python SDK for building text-based developer agents that Pip can hand conversations to.
Pipbit keeps the voice stack on the platform side:
- microphone and speaker handling
- speech-to-text and text-to-speech
- device transport
- request signing
- handoff session management
Your agent stays text-first and only needs to implement a webhook handler.
Installation
pip install pipbit
For local package work:
pip install -e '.[dev]'
Hello world
from pipbit import Agent, CONNECT_INTRO_UTTERANCE
agent = Agent(
name="george",
secret="pb_live_sk_XXXXXXXXXXXXXXXX",
base_url="https://api.pipbit.ai",
)
@agent.handle
def handle(req):
if req.is_connect_intro():
return "George here. How can I help with your home DIY today?"
return f"You said: {req.text}"
agent.run(host="0.0.0.0", port=3000)
Pipbit sends signed JSON requests to:
POST /pipbit/agent
CONNECT_INTRO_UTTERANCE is exported for agent authors who want the raw token,
but req.is_connect_intro() is the preferred helper.
Request model
Each inbound request is exposed as a Request object:
req.id
req.reply_token
req.session_id
req.text
req.conversation
req.subject_id
req.agent_session_id
req.device_shadow
req.is_connect_intro()
subject_idis the stable Pipbit subject id for the current user/device binding.session_idis the request/reply conversation id.agent_session_idis the higher-level Pip-managed handoff session.
Reply modes
Immediate reply:
@agent.handle
def handle(req):
return "Hi. How can I help?"
Deferred reply:
@agent.handle
def handle(req):
queue_work(req)
return req.defer()
Later:
agent.push_reply(
reply_token=req.reply_token,
text="Your report is ready.",
)
Proactive message:
agent.push_message(
subject_id=req.subject_id,
text="You have a new update.",
)
Health checks
The SDK exposes:
GET /healthGET /pipbit/health
The response is structured and readiness-aware. The SDK includes:
- a required
agent_secretcheck - a non-required
platform_healthcheck againstGET {base_url}/health
Add your own checks for agent-specific dependencies:
import os
from pipbit import Agent
agent = Agent(name="george", secret="pb_live_sk_...", base_url="https://api.pipbit.ai")
agent.add_health_check(
"openai_api_key",
lambda: (bool(os.getenv("OPENAI_API_KEY")), "Set OPENAI_API_KEY."),
required=True,
)
Example health response:
{
"status": "ok",
"ready": true,
"agent_name": "george",
"api_version": "v1",
"base_url": "https://api.pipbit.ai",
"checks": [
{"name": "agent_secret", "ok": true, "required": true, "message": "ok"},
{"name": "platform_health", "ok": true, "required": false, "message": "ok"}
]
}
If any required check fails, /health returns 503.
Metrics
The SDK exposes:
GET /metricsGET /pipbit/metrics
Current counters include:
webhook_requests_totalwebhook_success_totalwebhook_immediate_replies_totalwebhook_deferred_replies_totalwebhook_auth_failures_totalwebhook_invalid_requests_totalwebhook_configuration_errors_totalwebhook_handler_errors_totalpush_reply_calls_totalpush_message_calls_totalplatform_health_checks_totalplatform_health_check_errors_total
Local development
Run your Flask app locally:
python app.py
For local testing, expose your server so Pipbit can reach POST /pipbit/agent.
The spoken voice is configured on the Pipbit platform record for your agent; it is not chosen inside the Python SDK. The preferred platform contract is:
voice_request: developer-supplied abstract preference like presentation, tone, rolevoice_binding: platform-selected locked concrete voicevoice_id: bridge-compatible compatibility field derived from the binding
Legacy explicit voice_id registration still works, but new agents should
prefer voice_request.
Contract test
This repo includes an SDK contract test that exercises the basic developer flow:
- register agent
- bind device/subject
- connect the agent
- send the handoff intro turn
- send one normal user turn
- end the agent session
Run it from the repo root:
PYTHONPATH=SDK/pipbit_sdk:HOST/pipbit_platform_service \
python3 -m unittest SDK.pipbit_sdk.tests.test_contract -v
Packaging for PyPI
Build the sdist and wheel:
cd SDK/pipbit_sdk
python3 -m build
twine check dist/*
The repo also includes a RELEASE.md checklist for version bumps and publish steps.
Error handling
The SDK exposes:
AuthenticationErrorInvalidRequestErrorConfigurationError
Inbound webhook failures return JSON error bodies with sensible HTTP status codes.
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
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 pipbit-0.4.0.tar.gz.
File metadata
- Download URL: pipbit-0.4.0.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36aaba0fec69fc075add2be7e3d0ba7665f3b2ff736121208b5c2ef7ec976a2d
|
|
| MD5 |
50c3b8aeb41cac45db5430fc50d345b2
|
|
| BLAKE2b-256 |
d55416e03e08bcef0073ee4e8a469c5d53f464438c76bbae6a547d32cae0b737
|
File details
Details for the file pipbit-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pipbit-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209665413da7eb3f96d4c9601b69a145818b344a037559935f4ea8a2c870b1aa
|
|
| MD5 |
fe013f2415902322ad9951f729606082
|
|
| BLAKE2b-256 |
d60f7da9edf4e5cde15363f5a633094413ab69f9a61b82d329a16c48a8387362
|