Metadata-Version: 2.5
Name: philo-sdk
Version: 0.2.0
Summary: Python client for Philo digital-life conversations and video APIs
Project-URL: Homepage, https://developer.philoai.xyz
Project-URL: Documentation, https://developer.philoai.xyz/docs/en/
Project-URL: Getting started, https://developer.philoai.xyz/docs/en/get-started
Project-URL: Support, https://developer.philoai.xyz/docs/en/support
Author: Philo AI
License-Expression: LicenseRef-Philo-Proprietary
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Typing :: Typed
Requires-Python: <3.15,>=3.11
Requires-Dist: httpx<1,>=0.27
Requires-Dist: opencv-python-headless<5,>=4.10
Requires-Dist: sounddevice<0.6,>=0.5
Requires-Dist: websockets<16,>=15
Provides-Extra: camera
Provides-Extra: devices
Provides-Extra: microphone
Description-Content-Type: text/markdown

# Philo Python SDK

Use **CPython 3.13** (supported: standard CPython 3.11–3.14).
Install from [PyPI](https://pypi.org/project/philo-sdk/):

```bash
python -m pip install philo-sdk
```

For the version used by this guide:

```bash
python -m pip install "philo-sdk==0.2.0"
```

Microphone and camera Python dependencies are included. Installation opens no
hardware or API session. The [preparation guide](https://developer.philoai.xyz/docs/en/api-token)
covers Python setup, virtual environments, upgrades and OS device requirements.
Using the service requires your own Developer API Token and available quota.

## Start the Web Demo

After configuring `PHILO_API_KEY`, run:

```bash
philo demo
# Equivalent if the command is not on PATH:
python -m philo_sdk demo
```

Your browser opens a local page. Choose an authorized character and click Start.
Type, or enable the browser microphone/camera; watch the reply on the same page.
No ZIP download, separate portrait, reference voice or persona file is required.
The Token stays in Python. Devices start only when enabled; End stops capture
and requests cleanup, then displays the server's usage result.

Use `philo demo --language en` for an English conversation, `--port 8766` to choose
a local port, or `--no-browser` to print the URL without opening a browser.
The demo listens only on 127.0.0.1; keep the terminal open and use Ctrl+C to exit.
An uncertain remote outcome remains visible and never triggers automatic creation.

To make the interface yours:

```bash
philo demo --export ./my-demo
philo demo --web-dir ./my-demo
```

Edit `index.html`, `demo.css` and `demo.js` in that directory and refresh. Export
requires a new directory and never overwrites existing work. It needs no Token
and starts no service. Python implementation remains bytecode; UI files are editable.
For a hosted multi-user product, use the SDK behind your own authentication and UI.

## Start with a character

Set `PHILO_API_KEY` through your normal secret configuration. First list the
characters available to your Token; this does not start a session or upload media:

```python
import asyncio
import os
from philo_sdk import PhiloClient


async def main():
    async with PhiloClient(api_key=os.environ["PHILO_API_KEY"]) as client:
        page = 1
        while page is not None:
            result = await client.assets.characters.list(page=page, page_size=100)
            for role in result["items"]:
                if role.get("state") == "active" and role.get("available"):
                    print(role["id"], role["revision"], role["name"])
            page = result["next_page"]


asyncio.run(main())
```

Choose a character explicitly. Create an L2 session with
`character_asset=AssetRef(id, revision)` and a conversation language. The service
resolves its image, reference voice and persona. No local character materials
are required. The [complete quick start](https://developer.philoai.xyz/docs/en/public-assets)
includes selection, audiovisual output, stopping and usage; further examples
reuse the same selection for conversation, microphone, camera and text Memory.
Session creation can consume quota. Reading the character list cannot.

## Interfaces

| Interface | Purpose |
| --- | --- |
| `client.assets` | Authorized official characters and your private assets |
| `client.sessions.create(character_asset=…, language=…)` | Start with an existing character |
| `session.stream(media=True)` | Audiovisual output with explicit consumer feedback |
| `start_microphone()` / `start_camera()` | Send captured PCM / JPEG inputs |
| `session.export_memory()` | Export supported text state after a completed close |
| `session.stop()` / `session.usage()` | Request cleanup and read observed usage |
| `Character`, `Image`, `ReferenceVoice` | Advanced inline character materials |
| `client.video.create(...)` | Advanced L1 generation with final prompt and image |

Check capabilities and session readiness before use. Received media is distinct
from actual playback; the local Web Demo reports browser playback progress.
Text Memory is explicitly exported/imported; it is not a running-session backup.
No automatic replay of billable requests or reconnection is performed. Preserve
session/request IDs when outcomes are uncertain.

Tokens stay on your backend. The SDK connects only to its configured API origin,
does not follow redirects, and never needs infrastructure credentials. Official
assets are read-only; private asset updates require ownership and revision checks.

## Real microphone and camera

The standard installation includes the browser demo and Python device capture.
For additional editable terminal programs, download the
[complete editable examples](https://developer.philoai.xyz/docs/en/examples)
to run the microphone and camera programs. A versioned local-wheel bundle remains
available as an alternative; its `install.py` selects the matching wheel, and
third-party dependencies may still require internet access.

`philo_sdk.devices.MicrophoneCapture` yields 16 kHz mono PCM16 chunks;
`CameraCapture` yields proportionally resized JPEG frames. Both include UTC
capture timestamps. Use `async with` and `async for` to send them through an
already-ready `start_microphone()` or `start_camera()` input. Keep the session's
receiver running concurrently. Close the capture, input and session in `finally`.
The complete downloaded programs implement this lifecycle, device selection and
Ctrl+C: `python microphone.py`, `python camera.py --microphone`.

These commands reuse your selected managed character. To use local character
materials instead, append `--character my_character.json` to either command;
real devices work identically. `--wav speech.wav` and `--jpeg scene.jpg` are
explicit offline alternatives. No synthetic input is substituted on failure.

Run scripts on the computer that owns the devices, with a guarded
`if __name__ == '__main__':` entry point. Allow microphone/camera access in the
OS. Linux microphone capture may require `libportaudio2`; the microphone must
support 16 kHz mono input. No echo cancellation or resampling is provided: use
headphones. Audio overflow is an error, camera buffering keeps only the latest
frame. Native drivers run in owned processes with bounded shutdown; a blocked
driver is terminated without blocking session cleanup. Device libraries are loaded
only when capture is used; installing the SDK does not open any hardware.

## Python version and distribution

Use **CPython 3.13** for the tutorial. Bytecode wheels are supplied separately for
CPython 3.11, 3.12, 3.13 and 3.14; PyPy and other Python minors are not supported by
this release. Each wheel is tagged for its interpreter (for example
`cp313-none-any`), not a universal `py3` wheel. The SDK implementation is `.pyc`,
with `.pyi` API signatures for IDEs; editable examples remain Python source.
Bytecode is not encryption and contains no embedded credentials. Source archives
are internal build artifacts, not part of the downloadable example bundle.

The [installation guide](https://developer.philoai.xyz/docs/en/api-token) covers
macOS, Linux and Windows, including Python installation and upgrades. Create a
new virtual environment when upgrading Python, then reinstall the matching wheel;
do not copy `site-packages` from the old environment. The SDK wheel has no native
extension; its device dependencies and OS drivers still need platform support.
Linux CPU qualification does not imply physical-device or macOS/Windows testing.

## Documentation

- [Quick start](https://developer.philoai.xyz/docs/en/get-started)
- [Continue with the selected character](https://developer.philoai.xyz/docs/en/examples)
- [Customization and advanced use](https://developer.philoai.xyz/docs/en/advanced)
- [API and SDK reference](https://developer.philoai.xyz/docs/en/reference)

The SDK is proprietary; see the bundled LICENSE. Editable examples may be adapted
for your own Philo integrations. Third-party dependencies retain their own licenses.
