phi-agent Python SDK — build AI agents with Python, powered by Rust runtime
Project description
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
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 phi_agent-0.1.0.tar.gz.
File metadata
- Download URL: phi_agent-0.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34a3e519453449750548f4769f7594f42beabe2de7a0c30cba9a73c82e49cd1c
|
|
| MD5 |
242328d09e8b5d39bfe4749f31c8468f
|
|
| BLAKE2b-256 |
b3489551b9de9ebb470c4bda43dff27f366f116631b933f2712fa90ac67a34b8
|
File details
Details for the file phi_agent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: phi_agent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93754f4014233cd1fda8dd690388a2733cb28128c308c9389e0c544b1ebe10d1
|
|
| MD5 |
072b442646eee3542fad9bcbbe6492ab
|
|
| BLAKE2b-256 |
0372996b3a7bb9df3bd0005806b4622fc1f244997079ba064c824bda396b6a0a
|