Skip to main content

PYB Agent SDK (Python)

Python client SDK for the PYB Agent engine — with a built-in engine launcher: pip install is all you need; the SDK auto-discovers or spawns the engine on first use (zero-prerequisite install on platforms with a bundled wheel).

Install

pip install pyb-agent-sdk
  • Windows x64: a platform wheel with the bundled engine is selected automatically (py3-none-win_amd64, ~67MB) — no other setup needed.
  • Other platforms: the pure wheel installs the launcher, which reuses a running engine at http://localhost:4096 or spawns the pyb command from PATH (npm install -g pybao-xc-sdk provides it).

Quick start

import asyncio
from pyb_agent_sdk import PybAgentClient, ClientOptions

async def main():
    async with PybAgentClient(
        "http://localhost:4096",          # probed first; auto-spawn if dead
        options=ClientOptions(cwd="D:/proj"),
    ) as client:
        async for event in client.query("hello"):
            if event.type == "content_delta":
                print(event.text, end="")

asyncio.run(main())

First-run model configuration

The engine starts without credentials, but conversations require a model API key. Two options:

  1. Interactive: run pyb once in a terminal and complete model setup — stored in ~/.pyb/model-config-v2.sqlite.
  2. Environment: set ANTHROPIC_AUTH_TOKEN=<your key> before starting your Python process.

GLM keys: https://open.bigmodel.cn (the engine's default model family).

Without a key, the first query() fails with an actionable message pointing here (the engine's /health stays green — key issues surface per-turn, not at startup).

Engine version lock

The launcher validates the spawned engine's --version against a known-good floor (currently 1.5.281) and fails fast with upgrade guidance if the binary is older — instead of mysterious mid-conversation protocol errors.

Session pinning (shared live context)

Pass session_id= to the constructor to attach to an existing session — all clients on the same session share live context (server-side broadcast), e.g. ESP32 voice input and terminal CLI in one conversation.

API surface

  • PybAgentClient(base_url, *, session_id=None, options=None, can_use_tool=None)
  • await client.start() → session_id / await client.resume(session_id)
  • async for event in client.query(text) — content_delta / terminal events
  • await client.interrupt() — abort the running turn
  • SessionLostError — first-class: raised when the server lost the session

Metadata

Release files for pyb-agent-sdk 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyb-agent-sdk 0.2.1
File Size Uploaded
pyb_agent_sdk-0.2.1.tar.gz 43.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyb-agent-sdk 0.2.1
File Interpreter ABI Platform
pyb_agent_sdk-0.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pyb_agent_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 66.8 MB

Release files / pyb_agent_sdk-0.2.1.tar.gz

Download URL pyb_agent_sdk-0.2.1.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b6781fffa3777b3d7c077cb3feaee8b12eb50399000cea613515479a9aa5d0ec
BLAKE2b-256 checksum
How to use checksums
0bb981ce64fc8526b442c77c9e30bdf5d743c348195cb6acc890fd877bffb016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.10

Release files / pyb_agent_sdk-0.2.1-py3-none-win_amd64.whl

Download URL pyb_agent_sdk-0.2.1-py3-none-win_amd64.whl
Size 66.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
df3c81ee1aff956f2032d648f4683a75414648f9f75255ba579893c781a5856f
BLAKE2b-256 checksum
How to use checksums
814312e450d34ddd783d73807012742c76759ae34da45ba21681b1fad049dde7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.10

Release files / pyb_agent_sdk-0.2.1-py3-none-any.whl

Download URL pyb_agent_sdk-0.2.1-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe45378f156f79fe4e5b4aed798bb9a7b9531b612db6aafd3ad958db018a9711
BLAKE2b-256 checksum
How to use checksums
f35d4c3d1b160d5262bff405ed81436eaa68476ba1f352c79b8557ab29fc3da1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.10

Release history Release notifications | RSS feed

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

This release

0.2.1 This release

3 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page