phi-agent — Python SDK
Build AI agents with Python. Write tools in Python, run on a Rust-powered agent runtime.
Quick Start
import asyncio
from phi_agent import Agent, tool
@tool
async def get_time() -> str:
"""Get the current date and time."""
from datetime import datetime
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
async def main():
agent = Agent(model="gpt-4o")
agent.register(get_time)
async for event in agent.run("What time is it?"):
match event.type:
case "thought_delta": print(f"💭 {event.text}", end="", flush=True)
case "text_delta": print(event.text, end="", flush=True)
case "tool_call_started":
print(f"\n🔧 {event.tool_name}...")
case "tool_call_finished":
print(f" → {event.summary}")
asyncio.run(main())
How It Works
The Python SDK communicates with the phi Rust binary via stdio NDJSON protocol.
The Rust runtime handles the agent loop, session management, LLM calls, and event
streaming — you only write tools in Python.
Python process Rust process
┌──────────────┐ stdio ┌──────────────────┐
│ phi_agent │◄─ NDJSON ─►│ phi serve │
│ (your tools) │ │ (agent runtime) │
└──────────────┘ └──────────────────┘
- Protocol specification: phi-agent repo
License
MIT
Metadata
Release files for phi-agent 0.9.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phi_agent-0.9.1.tar.gz | 13.2 kB | Without provenance | Details for phi_agent-0.9.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phi_agent-0.9.1-py3-none-any.whl | Python 3 | none | any | Details for phi_agent-0.9.1-py3-none-any.whl |
Total release size: 26.0 kB
Release files / phi_agent-0.9.1.tar.gz
| Download URL | phi_agent-0.9.1.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab9eee69d6d063e827a40f1c436a1b17c676e58cae49d5cf37f0f4403ae02d5d
|
|
BLAKE2b-256 checksum How to use checksums |
741d7468ce83aafac14b9536e46f28f97d51be424c7688fa03356670d5758831
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.17
|
Release files / phi_agent-0.9.1-py3-none-any.whl
| Download URL | phi_agent-0.9.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94d92a74de8e181788b50748d3f4058357a53833d38561cf804e4a61cf29828e
|
|
BLAKE2b-256 checksum How to use checksums |
8bd6e270afee02113e9905a4f5f16a51175620f139a909f3a6c417b781968908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.17
|
Security for phi-agent 0.9.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.