Metadata-Version: 2.4
Name: phion-client
Version: 1.57.0
Summary: Budget-safe x402 client for PHION agent services
Author: PHION Systems
License-Expression: Apache-2.0
Project-URL: Homepage, https://phion.systems
Project-URL: Documentation, https://phion.systems/docs
Project-URL: Source, https://github.com/NeoNine0/phion-agent-connector
Project-URL: Issues, https://github.com/NeoNine0/phion-agent-connector/issues
Keywords: agents,mcp,x402,usdc,phion
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: x402<3,>=2.22
Requires-Dist: eth-account<1,>=0.13
Requires-Dist: requests<3,>=2.32
Provides-Extra: test
Requires-Dist: pytest<9,>=8; extra == "test"

# PHION Python client

Budget-safe synchronous x402 v2 client. It gets a non-paying quote, validates the
origin, Base network, official USDC contract, PHION recipient and maximum amount,
then delegates local signing and retry to the official `x402` SDK.

Installing this package never authorizes a payment. A paid call requires an
explicit `PhionBuyer.call(...)`, a locally supplied wallet key and a
`SpendingPolicy`. Use a dedicated low-balance wallet and set cumulative, call,
expiry and service-path limits through `SpendingMandate`.

```bash
python -m venv .venv
. .venv/bin/activate
pip install -e .
export EVM_PRIVATE_KEY=0x... # dedicated agent wallet; never commit this value
python example.py
```

The example has a hard limit of `0.001 USDC` and verifies the signed result.

The shortest verified workflow resolves first, then carries the resolution ID
through the bounded paid call:

```python
resolution = buyer.resolve(
    capability="inference",
    task="Return a one-sentence classification.",
)
candidate = next(
    (
        item for item in resolution["candidates"]
        if item.get("eligible") is True and item.get("serviceId") == "phion-inference"
    ),
    None,
)
if candidate is None:
    raise RuntimeError("no authorized candidate selected")
result = buyer.call(
    candidate["endpoint"],
    {"prompt": "Return a one-sentence classification."},
    mandate,
    trace={"resolution_id": resolution["resolutionId"]},
)
assert result["receipt_verified"] is True
```

`resolve()` is advisory: it never signs, pays or executes, and may honestly return
`ABSTAIN` when evidence is incomplete. `call()` preserves the spending policy and
quote checks and automatically verifies a signed receipt when a commercial result
is returned. Receipt verification proves integrity and origin, not that arbitrary
external source content is necessarily true.

The public MCP decision surface remains available without this package at
`https://phion.systems/mcp/decision`; start with `phion_resolve` in `PREFLIGHT`
mode when payment is not yet authorized.
